Compile: x86_64-w64-mingw32-gcc 6.1.1 20160815 (current version in Debian sid)
Target OS: Windows 10 Pro (Tranditional Chinese)
Test code:
Code: Select all
std::wstring ws = L"test";
printf("ws length = %d\n", ws.size());
// => ws length = 4
std::string s1 = fz::to_utf8(ws);
printf("s1 length = %d\n", s1.size());
// => s1 length = 4
std::string s2 = fz::to_string(ws);
printf("s2 length = %d\n", s2.size());
// => s2 length = 0
if (s1 == s2)
printf("s1 == s2\n");
else
printf("s1 != s2\n");
// => s1 != s2
std::wstring ws1 = fz::to_wstring(s1);
printf("ws1 length = %d\n", ws1.size());
// => ws1 length = 0
std::wstring ws2 = fz::to_wstring(s2);
// => ws2 length = 0
if (ws1 == ws2)
printf("ws1 == ws2\n");
else
printf("ws1 != ws2\n");
// => ws1 == ws2
std::wstring ws3 = fz::to_wstring_from_utf8(s1);
printf("ws3 length = %d\n", ws3.size());
// => ws3 length = 4
std::wstring ws4 = fz::to_wstring_from_utf8(s2);
printf("ws4 length = %d\n", ws4.size());
// => ws4 length = 0
if (ws3 == ws4)
printf("ws3 == ws4\n");
else
printf("ws3 != ws4\n");
// => ws3 != ws4
if (ws == ws3)
printf("ws == ws3\n");
else
printf("ws != ws3\n");
// => ws == ws3
fz::to_utf8() convert from wstring to utf-8 string
fz::to_wstring_from_utf8() convert from utf-8 string to wstring
Not work (it should work for English string):
fz::to_string() convert from wstring to string
fz::to_wstring() convert from string to wstring