mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[win] updatesvc: fix utf8 to utf16 conversion
This commit is contained in:
@ -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<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
str = converter.from_bytes(std::string(jstr->string, jstr->string_size));
|
||||
#else
|
||||
str = std::string(jstr->string, jstr->string_size);
|
||||
#endif
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
# include "platform_win/resource.h"
|
||||
# include "platform_win/utils.h"
|
||||
# include <Windows.h>
|
||||
# include <codecvt>
|
||||
# include <cwctype>
|
||||
# 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<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
return converter.from_bytes(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user