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 [
GetConsoleCPshows 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 [
GetConsoleOutputCPshows that it'scp866; OEM Russian; Cyrillic (DOS)for me]. - Be able to write to stdout the data came from source files (i.e.
const chararrays) [source files are encoded inUTF-8]. - Read and write data to UTF-8 encoded text files.
What I've tried:
- Combinations of
SetConsoleCPandSetConsoleOutputCPfunctions. - Combinations of
_setmode ()function and_O_U8TEXTmacros. setlocalestuff.- Combinations of point 1-3 and
wchar_tstrings, usingwscanf/wcinand L-strings.
So, is there a way to implement listed above functionality?