summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--messages.cpp18
-rw-r--r--utilities.cpp12
2 files changed, 3 insertions, 27 deletions
diff --git a/messages.cpp b/messages.cpp
index 5c6036d..8df3a2b 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -41,12 +41,6 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
{ //check for gpg related data
wstring str = toUTF16(msg);
- if(str.empty())
- {
- TCHAR *tmp = mir_a2t(msg);
- str += tmp;
- mir_free(tmp);
- }
wstring::size_type s1 = wstring::npos, s2 = wstring::npos;
if((str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos))
@@ -359,12 +353,6 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
return 1;
}
wstring str = toUTF16(msg);
- if(str.empty())
- {
- TCHAR *tmp = mir_a2t(msg);
- str += tmp;
- mir_free(tmp);
- }
mir_free((void**)pre->szMessage);
pre->szMessage = mir_strdup(toUTF8(str).c_str());
return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs);
@@ -405,12 +393,6 @@ int SendMsgSvc(WPARAM w, LPARAM l)
{ //encrypt data here
wstring str = toUTF16(msg);
- if(str.empty())
- {
- TCHAR *tmp = mir_a2t(msg);
- str += tmp;
- mir_free(tmp);
- }
{ //not xmpp, just replace whole message
string out;
DWORD code;
diff --git a/utilities.cpp b/utilities.cpp
index 5bba190..e857d5d 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -933,15 +933,9 @@ string toUTF8(wstring str)
wstring toUTF16(string str) //convert as much as possible
{
- string::iterator end_it = utf8::find_invalid(str.begin(), str.end());
- int length = utf8::distance(str.begin(), end_it);
wstring ustr;
- utf8::utf8to16(str.begin(), end_it, back_inserter(ustr));
- string tmp;
- while(end_it != str.end())
- str += *end_it;
- TCHAR *tmp2 = mir_a2t(tmp.c_str());
- ustr += tmp2;
- mir_free(tmp2);
+ string tmpstr;
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
return ustr;
} \ No newline at end of file