为什么nl_langinfo(CODESET)不同于locale charmap? [英] Why is nl_langinfo(CODESET) different from locale charmap?

查看:836
本文介绍了为什么nl_langinfo(CODESET)不同于locale charmap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此信息源自 http://stackoverflow.com/questions/1492918/how-do-you-get-what-kind-of-encoding-your-system-uses-in-cc

我尝试使用

nl_langinfo(CODESET)

但我得到ANSI_X3.4-1968而不是UTF-8(这是我得到当输入:locale charmap)。我使用nl_langinfo()错了吗?我应该如何使用它?

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

推荐答案

您需要先调用

setlocale(LC_ALL, "");

nl_langinfo总是提供关于当前语言环境的信息。

nl_langinfo always gives information about the current locale.

这篇关于为什么nl_langinfo(CODESET)不同于locale charmap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆