0

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:

  1. Read keyboard input from stdio using console [GetConsoleCP shows that it's cp866; OEM Russian; Cyrillic (DOS) for me]. Then it should be somehow converted to proper encoding to write these strings, so next:
  2. Be able to write to stdout the data came from stdin (with correct representation of characters) using console [GetConsoleOutputCP shows that it's cp866; OEM Russian; Cyrillic (DOS) for me].
  3. Be able to write to stdout the data came from source files (i.e. const char arrays) [source files are encoded in UTF-8].
  4. Read and write data to UTF-8 encoded text files.

What I've tried:

  1. Combinations of SetConsoleCP and SetConsoleOutputCP functions.
  2. Combinations of _setmode () function and _O_U8TEXT macros.
  3. setlocale stuff.
  4. Combinations of point 1-3 and wchar_t strings, using wscanf/wcin and L-strings.

So, is there a way to implement listed above functionality?

CoSalamander
  • 121
  • 7
  • 1
    Does this answer your question? [Properly print utf8 characters in windows console](https://stackoverflow.com/questions/10882277/properly-print-utf8-characters-in-windows-console) – Richard Critten Nov 23 '21 at 11:16
  • Maybe [this](https://github.com/amanuellperez/alp/blob/master/src/alp_utf8.h) can help you. And if you want an example of how to use that library, [look here](https://github.com/amanuellperez/alp/blob/master/src/test/utf8/main.cpp) – Antonio Nov 23 '21 at 15:58

0 Answers0