如何在C ++中获取系统的当前语言文化名称(来自语言环境) [英] How to get system's current language culture name (from locale) in C++

查看:133
本文介绍了如何在C ++中获取系统的当前语言文化名称(来自语言环境)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅以下链接中表格的第一列。我需要那种格式的语言文化名称。



语言文化名称,代码和ISO值方法表[C ++] [ ^ ]



目前我在使用GetLocaleInfo获取语​​言和国家名称的信息(然后像en-US一样连接它们)。但它失败了一些语言,如中文 - 简化。



对于简体中文,代码是zh-CHS .....我的方法给了我zh-CN。



获取此信息的正确方法是什么。



我尝试了什么:



目前我正在使用GetLocaleInfo来获取有关语言和国家/地区名称的信息(然后将它们连接起来像en-US)。但它失败了一些语言,如中文 - 简化。



对于简体中文,代码是zh-CHS .....我的方法给了我zh-CN。

Please see the first column of the table on following link. I need the language culture name in that format.

Table of Language Culture Names, Codes, and ISO Values Method [C++][^]

Currently i am using GetLocaleInfo to get the information aboout language and country name (and then concatenate them like en-US). But it fails for some languages like Chinese - simplified.

For chinese simplified the code is zh-CHS ..... My method gives me zh-CN.

What is the right way to get this information.

What I have tried:

Currently i am using GetLocaleInfo to get the information aboout language and country name (and then concatenate them like en-US). But it fails for some languages like Chinese - simplified.

For chinese simplified the code is zh-CHS ..... My method gives me zh-CN.

推荐答案

这个工作应该做你的 GetLocaleInfo ,带有正确的标志,如LOCALE_USER_DEFAULT。另请查看 GetLocaleInfoEx 及其各种标志。



这可能取决于Windows版本,并且可能在旧版Windows上失败,例如退役的XP。所以在Windows 10上进行测试。我不知道旧版Windows中是否存在一些错误。
This job should do your GetLocaleInfo with the correct flags like LOCALE_USER_DEFAULT. Also check out GetLocaleInfoEx and its various flags.

It may depend on the Windows version and may fail on older Windows like the retired XP. So test it on Windows 10. I wouldnt wonder if there is some bug in older Windows in that detail.


这篇关于如何在C ++中获取系统的当前语言文化名称(来自语言环境)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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