From f7e78b21e9655604ba6fba1d068a9bf7f00b85a5 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 6 Aug 2012 20:20:50 +0200 Subject: Font rendering - implemented rest of CText interface excluding some minor features --- src/common/stringutils.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/common/stringutils.cpp') diff --git a/src/common/stringutils.cpp b/src/common/stringutils.cpp index 585bb46..12a3179 100644 --- a/src/common/stringutils.cpp +++ b/src/common/stringutils.cpp @@ -135,15 +135,11 @@ int StrUtils::Utf8CharSizeAt(const std::string &str, unsigned int pos) size_t StrUtils::Utf8StringLength(const std::string &str) { size_t result = 0; - for (unsigned int i = 0; i < str.size(); ++i) + unsigned int i = 0; + while (i < str.size()) { - char ch = str[i]; - if ((ch & 0x80) == 0) + i += Utf8CharSizeAt(str, i); ++result; - else if ((ch & 0xC0) == 0xC0) - result += 2; - else - result += 3; } return result; } -- cgit v1.2.3-1-g7c22