diff --git a/win-linux/extras/update-daemon/src/classes/cjson.cpp b/win-linux/extras/update-daemon/src/classes/cjson.cpp index 03aea59bf..aedcfbe12 100644 --- a/win-linux/extras/update-daemon/src/classes/cjson.cpp +++ b/win-linux/extras/update-daemon/src/classes/cjson.cpp @@ -99,12 +99,8 @@ tstring JsonValue::toTString() if (pimpl->val && pimpl->val->type == json_type_string) { json_string_s *jstr = (json_string_s*)pimpl->val->payload; #ifdef _WIN32 - size_t len = jstr->string_size, outSize = 0; - wchar_t *pDestBuf = new wchar_t[len + 1]; - mbstowcs_s(&outSize, pDestBuf, len + 1, jstr->string, len); - if (outSize > 0) - str = pDestBuf; - delete[] pDestBuf; + std::wstring_convert> converter; + str = converter.from_bytes(std::string(jstr->string, jstr->string_size)); #else str = std::string(jstr->string, jstr->string_size); #endif diff --git a/win-linux/extras/update-daemon/src/classes/translator.cpp b/win-linux/extras/update-daemon/src/classes/translator.cpp index 2e1d77aac..2f5e3b8e9 100644 --- a/win-linux/extras/update-daemon/src/classes/translator.cpp +++ b/win-linux/extras/update-daemon/src/classes/translator.cpp @@ -4,6 +4,7 @@ # include "platform_win/resource.h" # include "platform_win/utils.h" # include +# include # include # define istalnum(c) std::iswalnum(c) # define istalpha(c) std::iswalpha(c) @@ -55,10 +56,8 @@ tstring getPrimaryLang(const tstring &lang, bool withScript = false) #ifdef _WIN32 wstring StrToWStr(const string &str) { - size_t len = str.length(), outSize = 0; - wstring wstr(len, '\0'); - mbstowcs_s(&outSize, &wstr[0], len + 1, str.c_str(), len); - return wstr.c_str(); + std::wstring_convert> converter; + return converter.from_bytes(str); } #endif