以英语获取OS语言 [英] Getting OS Language in English

查看:68
本文介绍了以英语获取OS语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以获取OS语言,例如中文(简体).我尝试使用CultureInfo.CurrentCulture.EnglishName,但是在某些语言(例如葡萄牙语巴西,中文(简体)等)上,它会检索英语.有人可以帮我吗.

Is there any way I can get the OS language like Chinese (Simplified). I tried with CultureInfo.CurrentCulture.EnglishName but on certain languages like Portuguese Brazil, Chinese (Simplified), etc., it retrieves English. Can anybody help me with this.

推荐答案


如果它检索英语,则表示是英语.我怀疑您将某些语言与文化混淆了.您会看到,.NET完全支持Unicode.在内部,所有字符串都使用Unicode编码UTF-16在内存中表示,每个字符一个或两个16位字(两个字称为代理对,用于表示BMP以外的字符,基本多语言纯文本) .它使程序可以使用任何语言(甚至可以在一个控件中使用多种语言,例如Label,TextBox或TextBlock)为线程分配什么文化.文化是与语言相关但与语言无关的东西.它定义了将使用的卫星组件(如果有)以及数字表示,日期/时间等.

我希望这是唯一的问题.请检查什么文化真正分配给线程.如果看不到它,请尝试对其进行明确分配并回读.我认为您应该获得匹配的结果.

另请参见:
http://unicode.org/ [ ^ ],
http://unicode.org/faq/utf_bom.html [
If it retrieves English, it means the CurrectCulture is English. I suspect you''re confusing using some language with culture. You see, .NET fully supports Unicode; internally, all strings are represented in memory using Unicode encoding UTF-16, one or two 16-bit words per characters (two words are called surrogate pair and used to represent characters beyond BMP, Basic Multilingual Plain). It allows program to work with any language (and even with several different language in one control like a Label, TextBox or TextBlock) no matter what culture is assigned to a thread. Culture is something associated to language but independent on it. It defines what satellite assemblies will be used (if any) and also such thing as representation of numerals, date/time, etc.

I hope this is the only problem. Please check up what culture was really assigned to a thread. If you cannot see it, try to assign it explicitly and read back; I think you should get matching results.

See also:
http://unicode.org/[^],
http://unicode.org/faq/utf_bom.html[^].

—SA


这篇关于以英语获取OS语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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