diff options
Diffstat (limited to 'utilities.cpp')
-rwxr-xr-x | utilities.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/utilities.cpp b/utilities.cpp index 9d2a9be..b651558 100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -1138,7 +1138,14 @@ int returnNoError(HANDLE hContact) { string toUTF8(wstring str) { string ustr; + try{ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr)); + } + catch(const utf8::exception& e) + { + debuglog<<std::string("utf8cpp encoding exception: ")+(char*)e.what(); + //TODO + } return ustr; } @@ -1148,8 +1155,15 @@ wstring toUTF16(string str) //convert as much as possible { wstring ustr; string tmpstr; + try{ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr)); utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr)); + } + catch(const utf8::exception& e) + { + debuglog<<std::string("utf8cpp decoding exception: ")+(char*)e.what(); + //TODO + } return ustr; } |