I am developing on the macOS operating system. There are heaps of problems with Cyrillic (string or char *), for example, when working with the functions regex, :: tolower / :: toupper, etc.
When I ask for locale in the terminal, I have the following:
LANG="ru_RU.UTF-8" LC_COLLATE="ru_RU.UTF-8" LC_CTYPE="ru_RU.UTF-8" LC_MESSAGES="ru_RU.UTF-8" LC_MONETARY="ru_RU.UTF-8" LC_NUMERIC="ru_RU.UTF-8" LC_TIME="ru_RU.UTF-8" LC_ALL=
I am using C ++ 11. I don’t want to use Boost in principle, and it is desirable that the solution could be ported to linkus in the future (a reference to the non-portable codecvt).
Actually the question itself: how can you fix the problem of the Cyrillic alphabet in the entire program? For example, to use correctly locale.h (and how is it competently?) Or something else.
I output the text directly to the console. The output to the console is excellent, but transformations using transform using the :: tolower, :: toupper parameters are successfully ignored. Using codecvt I was able to get from string -> wstring, executed :: tolower and could also do wstring-> string, however, this is an obvious "crutch" and use it whenever I need to do something with the bytes of the string – not an option …
If I output Russian text in ncurses, it turns out like this: (I'm some kind of text) "What am I -? ~ Bo? ~ Age? ~ A? ~ B"
I really understand your desire not to use Boost (this is also a principle).
To forget about encoding problems once and for all, it is best to use utf8 and the STL has its
wstring str = u8"кириллический текст";//u8 преобразует ansi символы в utf8.
You can forget about locale problems using
From the pros, this is portability to anything, and from the minuses, this is increased memory consumption (not fatal, but still).
And by the way, it is considered a good form not to use
std::cout (as well as a pair of
std::cin ) within the same application (there are problems with their sharing).