Answer the question
In order to leave comments, you need to log in
How to use unicode in windows console with wstring?
Tried the most popular options.
At the moment, progress has stopped at this point:
system( "chcp 65001" );
_setmode( _fileno( stdout ), _O_U8TEXT );
_setmode( _fileno( stdin ), _O_U8TEXT );
std::wcout << L"строка" << std::endl;
std::wcout << L"string" << std::endl;
std::wstring test;
std::wcout << L"input: ";
std::wcin >> test;
std::wcout << test << std::endl;
Active code page: 65001
строка
string
input: строка
Press <RETURN> to close this window...
Answer the question
In order to leave comments, you need to log in
The command line arguments will not necessarily be in 866 encoding, they can be in 1251 as well - it depends on the console encoding, which can be changed with the chcp console command.
In general, you should not use Unicode in the console, because the Windows console is not too friendly with Unicode.
For example, if you want to process the output of your program with some kind of filter in a batch file, then there may be problems with Unicode.
Although you can use unicode inside a program, in this case you will have to recode all input and output. Not sure if the standard library can be configured to do the transcoding itself.
And so in WinAPI there is a whole set of console functions, incl. you can get the current console encoding for input and output, set the desired encoding, recode the text.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question