开发者

Getting the current locale's charset in C?

开发者 https://www.devze.com 2023-04-10 05:08 出处:网络
How can I find the current locale\'s charset in C? setlocale(LC_ALL, NULL) returns \"en_US.UT开发者_开发知识库F8\", but is there a way to get the charset? In /etc/locale.gen on my system it lists the

How can I find the current locale's charset in C?

setlocale(LC_ALL, NULL) returns "en_US.UT开发者_开发知识库F8", but is there a way to get the charset? In /etc/locale.gen on my system it lists the locales and the charsets, so it's not in the name.


You can query various parameters of the current locale using the nl_langinfo(3) function. The charset is obtained by calling nl_langinfo(CODESET).

Note, that you have to call setlocale before using nl_langinfo to make your program locale-aware.

0

精彩评论

暂无评论...
验证码 换一张
取 消