summaryrefslogtreecommitdiff
path: root/plugins/StopSpamMod/src/utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/StopSpamMod/src/utilities.cpp')
-rwxr-xr-xplugins/StopSpamMod/src/utilities.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp
index ac47d6d7b0..7943dada3f 100755
--- a/plugins/StopSpamMod/src/utilities.cpp
+++ b/plugins/StopSpamMod/src/utilities.cpp
@@ -331,41 +331,25 @@ void HistoryLogFunc(MCONTACT hContact, std::string message)
std::string msg = message;
msg.append("\n");
msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: ");
- msg.append(toUTF8((wchar_t*)pcli->pfnGetContactDisplayName(hContact, 0))).append(" ID: ");
+ msg.append(toUTF8(pcli->pfnGetContactDisplayName(hContact, 0))).append(" ID: ");
msg.append(toUTF8(GetContactUid(hContact, toUTF16(GetContactProto(hContact)))));
HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ);
}
}
-std::string toUTF8(std::wstring str)
+std::wstring toUTF16(std::string str) //convert as much as possible
{
- std::string ustr;
- try {
- utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
- }
- catch (const std::exception&) {
- //TODO: handle utf8cpp exceptions
- }
- return ustr;
+ return std::wstring(ptrW(mir_utf8decodeW(str.c_str())));
}
-std::string toUTF8(std::string str)
+std::string toUTF8(std::wstring str)
{
- return toUTF8(toUTF16(str));
+ return std::string(ptrA(mir_utf8encodeW(str.c_str())));
}
-std::wstring toUTF16(std::string str) //convert as much as possible
+std::string toUTF8(std::string str)
{
- std::wstring ustr;
- std::string tmpstr;
- try {
- utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
- utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
- }
- catch (const std::exception &) {
- //TODO: handle utf8cpp exceptions
- }
- return ustr;
+ return toUTF8(toUTF16(str));
}
std::string get_random_num(int length)