Why is nl_langinfo (CODESET) different from charmap locale?

This message came from How do you get what encoding your system uses in c / C ++?

I tried to use

nl_langinfo(CODESET)

but I got ANSI_X3.4-1968 instead of UTF-8 (this is what I get when typing: charmap). Am I using nl_langinfo () incorrectly? How to use it?

+3
source share
1 answer

You need to call first

setlocale(LC_ALL, "");

nl_langinfo always provides information about the current language version.

+3
source

Source: https://habr.com/ru/post/1719946/


All Articles