When I enter 'café' in Windows console, in the wide string I got 'caf' 'c' code : 99 'a' code : 97 'f' code : 102 '' code : 130 or other strange values with the stuff I found in the internet,... 233 is the correct value which is the UTF-8 code for 'é'
#undef UNICODE
#define UNICODE
wstring wstrCharsList;
std::getline(wcin, wstrCharsList);
if (!std::wcin.good()) cout << "problem !\n";
wcout << wstrCharsList << std::endl;
I tried ALL the stuff I found on the other SO questions and on the web (especially : https://alfps.wordpress.com/2011/12/08/unicode-part-2-utf-8-stream-mode/) and nothing worked.
I need a wstring encoded with UTF8 to provide it to my API to perform some string comparisons (with strings loaded from a text UTF-8 encoded file.)
NB: On Linux my program works correctly. FU Microsoft.
I need a wstring encoded with UTF8What?! You're trying to store UTF-8 characters in a wide string? That's the exact opposite of what it's intended for -- you need a regular 8-bit string for UTF-8, period. On any platform. - MrEricSir_setmodeto receive the correctstd::wstring, then compare it with anotherstd::wstring. See this SO answer stackoverflow.com/a/40417293/4603670 - UseWideStringToMultibyteto convert UTF16 to UTF8 (but I don't think you need that here). Note that windows console has limited Unicode support for some Asian languages. - Barmak Shemirani