diff options
author | Daniel Wilhelm <daniel@wili.li> | 2015-10-02 14:50:33 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2015-10-02 14:50:33 +0200 |
commit | b6d9c83c8386c83f0e2c3ffeaded184f60635bb4 (patch) | |
tree | b404f53d08361eef07350d21f4002f8b1def711c /zen/utf.h | |
parent | 6.6 (diff) | |
download | FreeFileSync-b6d9c83c8386c83f0e2c3ffeaded184f60635bb4.tar.gz FreeFileSync-b6d9c83c8386c83f0e2c3ffeaded184f60635bb4.tar.bz2 FreeFileSync-b6d9c83c8386c83f0e2c3ffeaded184f60635bb4.zip |
6.7
Diffstat (limited to 'zen/utf.h')
-rw-r--r-- | zen/utf.h | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -247,7 +247,6 @@ size_t unicodeLength(const CharString& str, char) //utf8 while (strFirst < strLast) //[!] { ++len; - size_t utf8len = getUtf8Len(*strFirst); if (utf8len == 0) ++utf8len; //invalid utf8 character strFirst += utf8len; @@ -311,13 +310,15 @@ size_t findUnicodePos(const CharString& str, size_t unicodePos, char) //utf8-cha size_t utfPos = 0; while (unicodePos-- > 0) { + if (utfPos >= strLen) + return strLen; + size_t utf8len = getUtf8Len(strFirst[utfPos]); if (utf8len == 0) ++utf8len; //invalid utf8 character utfPos += utf8len; - - if (utfPos >= strLen) - return strLen; } + if (utfPos >= strLen) + return strLen; return utfPos; } @@ -333,13 +334,15 @@ size_t findUnicodePosWide(const WideString& str, size_t unicodePos, Int2Type<2>) size_t utfPos = 0; while (unicodePos-- > 0) { - size_t utf16len = getUtf16Len(strFirst[utfPos]); - if (utf16len == 0) ++utf16len; //invalid utf16 character - utfPos += utf16len; - if (utfPos >= strLen) return strLen; + + size_t utf16len = getUtf16Len(strFirst[utfPos]); + if (utf16len == 0) ++utf16len; //invalid utf16 character + utfPos += utf16len; } + if (utfPos >= strLen) + return strLen; return utfPos; } |