diff --git a/utf8.h b/utf8.h index 80c7642..17b2f33 100644 --- a/utf8.h +++ b/utf8.h @@ -79,6 +79,12 @@ struct string32 { string32() {} + string32 substr(int start, int end=-1) { + if (end == -1) + end = cs.size(); + return string32(*this, start, end); + } + int length() const { return cs.size(); } @@ -158,8 +164,106 @@ struct string32 { return false; } - void replaceSelfAll(string32 find, string32 with) { - while (replaceSelf(find, with)); + void replaceSelfAll(string32 findWrapper, string32 withWrapper) { + while (replaceSelf(findWrapper, withWrapper)); + } + + string32 reverse() { + string32 tmpStr; + for (int i(cs.size());i>=0;i--) + tmpStr += cs[i]; + return tmpStr; + } + + bool replaceAroundSelf(string32 findWrapper, string32 withWrapper) { + int havematched = 0; + int tofind (findWrapper.cs.size()); + int i = 0; + for (;i split(string32 delim) { @@ -202,6 +306,12 @@ struct string32 { int len() { return cs.size(); } + + void rebuildSize() { + size = 0; + for (char32 c : cs) + size += c.size; + } }; string32 operator+(char* s1, string32 s2) {