diff options
author | Paul Baltescu <pauldb89@gmail.com> | 2013-05-23 20:42:26 +0100 |
---|---|---|
committer | Paul Baltescu <pauldb89@gmail.com> | 2013-05-23 20:42:26 +0100 |
commit | 1f9e57479e1c03d208e0b2b7bf007426e8a16dab (patch) | |
tree | 41176fdd936eba591cd2d88ea1f7a2ad76f8cc36 /utils | |
parent | 124878154b88819d35e78a42b854054bfc90e1b1 (diff) | |
parent | fc3d47b81448c7537ed7951aea81ddcbd95bc18a (diff) |
Merge branch 'master' of github.com:pauldb89/cdec
Diffstat (limited to 'utils')
-rw-r--r-- | utils/filelib.h | 2 | ||||
-rw-r--r-- | utils/stringlib.h | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/utils/filelib.h b/utils/filelib.h index bb6e7415..b9ea3940 100644 --- a/utils/filelib.h +++ b/utils/filelib.h @@ -27,7 +27,7 @@ struct BaseFile { } bool is_null() const { return !ps_; } operator bool() const { - return ps_; + return ps_.get(); } S* stream() { return ps_.get(); } S* operator->() { return ps_.get(); } // compat with old ReadFile * -> new Readfile. remove? diff --git a/utils/stringlib.h b/utils/stringlib.h index ff5dc89d..1bb533d8 100644 --- a/utils/stringlib.h +++ b/utils/stringlib.h @@ -268,6 +268,16 @@ inline unsigned int UTF8Len(unsigned char x) { else return 0; } +inline unsigned int UTF8StringLen(const std::string& x) { + unsigned pos = 0; + int len = 0; + while(pos < x.size()) { + ++len; + pos += UTF8Len(x[pos]); + } + return len; +} + std::string md5(const std::string& in); #endif |