diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-05-27 23:36:18 +0300 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr> | 2010-05-27 23:24:59 +0200 |
commit | 6c91c7eed18ad377484e7f0edf6eff520f056c13 (patch) | |
tree | 1dc0ae52cb45b9393429e7092f6501d4b073179c /src/utils/stringutils.cpp | |
parent | ad34e7cf98b7a4d7096b66c743e4a087d9b432dd (diff) | |
download | mana-6c91c7eed18ad377484e7f0edf6eff520f056c13.tar.gz mana-6c91c7eed18ad377484e7f0edf6eff520f056c13.tar.bz2 mana-6c91c7eed18ad377484e7f0edf6eff520f056c13.tar.xz mana-6c91c7eed18ad377484e7f0edf6eff520f056c13.zip |
Fix drawing incorrect utf8 strings issue.
Reviewed-by: Bertram
Resolve: Manasource Mantis #143
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 01bf0d3c..9fe3de14 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -21,10 +21,13 @@ #include "utils/stringutils.h" +#include <string.h> #include <algorithm> #include <cstdarg> #include <cstdio> +const int UTF8_MAX_SIZE = 10; + std::string &trim(std::string &str) { std::string::size_type pos = str.find_last_not_of(' '); @@ -164,3 +167,11 @@ const std::string findSameSubstring(const std::string &str1, const std::string & } return str1.substr(0, minLength); } + +const char* getSafeUtf8String(std::string text) +{ + char* buf = new char[text.size() + UTF8_MAX_SIZE]; + memcpy(buf, text.c_str(), text.size()); + memset(buf + text.size(), 0, UTF8_MAX_SIZE); + return buf; +}
\ No newline at end of file |