summaryrefslogtreecommitdiff
path: root/utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utilities.cpp')
-rw-r--r--utilities.cpp22
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