diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2011-11-03 20:37:56 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2011-11-03 20:37:56 +0200 |
commit | 24f43db848336aec381d0d61f30e5ec067905e32 (patch) | |
tree | 435385b32fd3abc98e4ef681fbf453f20c7b279e /utilities.cpp | |
parent | 16a477058f150f46a99e2f60cd51502c04a1ed9c (diff) |
basic utf8cpp exceptions handling
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; } |