summaryrefslogtreecommitdiff
path: root/utils/stringlib.h
diff options
context:
space:
mode:
authorPaul Baltescu <pauldb89@gmail.com>2013-05-23 20:42:26 +0100
committerPaul Baltescu <pauldb89@gmail.com>2013-05-23 20:42:26 +0100
commit4ab38fecf0f49c5132a5d5ea748d03e0acfa36c2 (patch)
tree8e250d99f4a381eae865a15b6eb43b0f77b68479 /utils/stringlib.h
parent35d2c095ba6a912272f2fcc8322ece4213ada82b (diff)
parent1d96c9c9c521edfca1d10e4d8c5064f79fda3ec5 (diff)
Merge branch 'master' of github.com:pauldb89/cdec
Diffstat (limited to 'utils/stringlib.h')
-rw-r--r--utils/stringlib.h10
1 files changed, 10 insertions, 0 deletions
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