Skip to content

Commit 9587542

Browse files
committed
Fix the non-Win32 version of Language::cpToWstr().
1 parent 4a07439 commit 9587542

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Engine/Language.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,11 @@ std::wstring Language::cpToWstr(const std::string& src)
418418
return wstr;
419419
#else
420420
const int MAX = 500;
421-
wchar_t buffer[MAX];
422-
mbstowcs(buffer, src.c_str(), MAX);
423-
std::wstring wstr(buffer);
424-
return wstr;
421+
wchar_t buffer[MAX + 1];
422+
size_t len = mbstowcs(buffer, src.c_str(), MAX);
423+
if (len == (size_t)-1)
424+
return L"?";
425+
return std::wstring(buffer, len);
425426
#endif
426427
}
427428

0 commit comments

Comments
 (0)