diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-21 05:34:01 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-21 05:34:01 +0300 |
commit | d5baf212f45c3926ffec3bccad77ca4dd0751d23 (patch) | |
tree | 4f32bd925082bc78ecdcf0a1e98b53655a8faa69 /utilities.cpp | |
parent | 64624c111e4a8a3a156190a8d6d3ee4d2e528f39 (diff) |
using utf8<->utf16 on poor c++ instead of miranda api (can solve some issues with badly encoded messages, testing needed)
Diffstat (limited to 'utilities.cpp')
-rw-r--r-- | utilities.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/utilities.cpp b/utilities.cpp index 8ebe6f0..02ff474 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -542,9 +542,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU path_out += _T("\\prescense_text"); DeleteFile(path_out.c_str()); wfstream f(path_out.c_str(), std::ios::out); - char *tmp = mir_utf8encodeW(str); - f<<tmp; - mir_free(tmp); + f<<toUTF8(str).c_str(); f.close(); if(_waccess(path_out.c_str(), 0) == -1) { @@ -714,9 +712,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi sign_file_mutex.lock(); DeleteFile(path_out.c_str()); wfstream f(path_out.c_str(), std::ios::out); - char *tmp = mir_utf8encodeW(sign.c_str()); - f<<tmp; - mir_free(tmp); + f<<toUTF8(sign).c_str(); f.close(); if(_waccess(path_out.c_str(), 0) == -1) { @@ -914,3 +910,17 @@ int returnNoError(HANDLE hContact) { SetEvent( hEvent );
return 777;
}
+
+string toUTF8(wstring str)
+{
+ string ustr;
+ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ return ustr;
+}
+
+wstring toUTF16(string str)
+{
+ wstring ustr;
+ utf8::utf8to16(str.begin(), str.end(), back_inserter(ustr));
+ return ustr;
+}
\ No newline at end of file |