I want to use Cyrillic letters in my application, and I decided to use UTF-8 encoding to store any text data. I'm using MinGW on Windows 7, source files are encoded in UTF-8. I read a lot of info about encoding and different ways to convert strings, change locales, set stream modes and etc., but I didn't find a proper way to implement all next needs at once:
- Read keyboard input from stdio using console [
GetConsoleCP
shows that it'scp866; OEM Russian; Cyrillic (DOS)
for me]. Then it should be somehow converted to proper encoding to write these strings, so next: - Be able to write to stdout the data came from stdin (with correct representation of characters) using console [
GetConsoleOutputCP
shows that it'scp866; OEM Russian; Cyrillic (DOS)
for me]. - Be able to write to stdout the data came from source files (i.e.
const char
arrays) [source files are encoded inUTF-8
]. - Read and write data to UTF-8 encoded text files.
What I've tried:
- Combinations of
SetConsoleCP
andSetConsoleOutputCP
functions. - Combinations of
_setmode ()
function and_O_U8TEXT
macros. setlocale
stuff.- Combinations of point 1-3 and
wchar_t
strings, usingwscanf
/wcin
and L-strings.
So, is there a way to implement listed above functionality?