How to write Cyrillic text in C++ console?

Posted by VextoR on Stack Overflow See other posts from Stack Overflow or by VextoR
Published on 2010-02-14T15:03:44Z Indexed on 2012/06/17 15:16 UTC
Read the original article Hit count: 206

Filed under:
|
|

For example, if I write:

cout << "??????!" << endl; //it's hello in Russian

in console it would be something like "-?????!"

ok, I know that we can use:

setlocale(LC_ALL, "Russian");

but after that not working command line arguments in russian (if I start my program through BAT file):

StartProgram.bat

chcp 1251
MyProgram.exe -user=???? -password=??????

so, after setlocale program can't read russian arguments properly.

This happens because BAT file in CP1251, but console is in CP866

So, there is a question:

How to write in C++ console russian text and same time russian command line arguments have to be read properly

thanks

© Stack Overflow or respective owner

Related posts about c++

Related posts about encoding