
please wait
|
|
SetConsoleOutputCP()
function. Finally, when you open a file in a text editor, how the bytes in that file will appear as text again totally depends which character encoding your specific text editor assumes! A proper text editor will allow you to choose the desired encoding...°
is encoded as a single byte with the value 0xB0
. But, in Code Page 437 (OEM), that very same characters is encoded as the byte value 0xF8
. And, in UTF-8 encoding, that very same character even is encoded as the byte sequence 0xC2
+ 0xB0
😏std::string
is kind of "agnostic" to character encoding; it just stores char
's (bytes).GetConsoleCP()
to determine the actual console input code-page (character encoding) – which could be different on each machine.MultiByteToWideChar()
to convert the char*
string, which you have read from the terminal, from the console input code-page (as determined previously) to a wchar_t*
(UTF-16) string.wchar_t*
(UTF-16) string could again be converted to a char*
string, in whichever code-page that you like (probably UTF-8), by using WideCharToMultiByte()
, and then be written to the file.