2021-07-10
07:19 PM
- last edited on
2021-09-14
09:28 AM
by
Noemi Balogh
char orig_utf8[8];
orig_utf8[0] = 0x6b;
orig_utf8[1] = 0xc3;
orig_utf8[2] = 0xa1;
orig_utf8[3] = 0x74;
orig_utf8[4] = 0x79;
orig_utf8[5] = 0xc3;
orig_utf8[6] = 0xba;
orig_utf8[7] = 0x00;
GS::UniString gs_str_in(orig_utf8, CC_UTF8);
ACAPI_WriteReport(gs_str_in, true); //reports "kátyú", this is the real utf8 string
GS::UChar c1, c2, c3, c4, c5;
c1 = gs_str_in.GetChar(0);
c2 = gs_str_in.GetChar(1);
c3 = gs_str_in.GetChar(2);
c4 = gs_str_in.GetChar(3);
c5 = gs_str_in.GetChar(4);
GS::UniString result("");
result += c1;
result += c2;
result += c3;
result += c4;
result += c5;
ACAPI_WriteReport(result, true); //reports "kktyy" - why?
Outputs: Why does it report "kktyy"?2021-07-11 11:26 AM
str.ToCStr (0, MaxUSize, CC_UTF8)).Get ();
std::wstring ToWString (const GS::UniString& str)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> convert;
return std::wstring (convert.from_bytes (str.ToCStr (0, MaxUSize, CC_UTF8)));
}