diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-06-13 13:16:16 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-06-13 13:16:16 -0600 |
commit | e8bea8a6edf69e824a922adeb5e697111ceabe90 (patch) | |
tree | db1937956bc585b300f2a2c8312af4ad5bf924de /src/utils | |
parent | 593fd2b831304c8e421589aab0fb158e4b7e9c35 (diff) | |
parent | 0b15a3ad32838134384524ce4af95d65b0b4e5da (diff) | |
download | mana-e8bea8a6edf69e824a922adeb5e697111ceabe90.tar.gz mana-e8bea8a6edf69e824a922adeb5e697111ceabe90.tar.bz2 mana-e8bea8a6edf69e824a922adeb5e697111ceabe90.tar.xz mana-e8bea8a6edf69e824a922adeb5e697111ceabe90.zip |
Merge remote branch '1.0/1.0'
Conflicts:
data/graphics/CMakeLists.txt
data/graphics/Makefile.am
src/client.cpp
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/stringutils.cpp | 11 | ||||
-rw-r--r-- | src/utils/stringutils.h | 2 |
2 files changed, 13 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 diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 5e4718c0..ec82e240 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -123,4 +123,6 @@ bool isWordSeparator(char chr); const std::string findSameSubstring(const std::string &str1, const std::string &str2); +const char* getSafeUtf8String(std::string text); + #endif // UTILS_STRINGUTILS_H |