summaryrefslogtreecommitdiff
path: root/utils/stringlib.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@Chriss-MacBook-Air.local>2013-05-06 22:22:36 -0400
committerChris Dyer <cdyer@Chriss-MacBook-Air.local>2013-05-06 22:22:36 -0400
commitbed260cb57fc8fb604a8a9e391321f777a697ec4 (patch)
tree066eb6a87e2c2aaebb9ac8f513bce434a0938789 /utils/stringlib.h
parent2e4b60f35c40af366be40fe7089f21a5c1ad8e71 (diff)
fix
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