在.NET转换国家codeS [英] Converting country codes in .NET
问题描述
在.NET中有没有什么办法可以从三个字母的国家codeS(ISO 3166-1中的α-3中定义),以两个字母的语言codeS转换(定义在ISO 3166-1α-2)例如。转换BEL是?
In .NET is there any way to convert from three letter country codes (defined in ISO 3166-1 alpha-3) to two letter language codes (defined in ISO 3166-1 alpha-2) eg. convert BEL to BE?
已经看过在System.Globalization的RegionInfo类,但构造似乎并不支持这三个字母codeS。
Have looked at the RegionInfo class in System.Globalization but the constructor does not seem to support the three letter codes.
推荐答案
在 RegionInfo
类不知道这三个字母的code(在<一个href="http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.threeletterisoregionname.aspx"><$c$c>ThreeLetterISORegionName$c$c>物业),但我不认为有一种方式来获得 RegionInfo
在此基础上code,则需要枚举所有地区,并将它们添加到您自己的字典,用三个字母code作为重点。
The RegionInfo
class does know the three-letter code (in the ThreeLetterISORegionName
property), but I don’t think there is a way to get RegionInfo
based on this code, you would need to enumerate all regions and add them to your own dictionary, with the three-letter code as a key.
不过,我认为在.NET Framework使用 RegionInfo
一起工作的文化的,而不是在ISO 3166-1意义上的国家。因此,从ISO 3166-1标准中的许多国家都不可用(试行例如 SX
)。我想你应该建立自己的国家codebook。
However, I think the .NET Framework uses RegionInfo
to work with cultures, not countries in the ISO 3166-1 sense. Therefore, many countries from the ISO 3166-1 standard are not available (try e.g. SX
). I guess you should create your own country codebook.
编辑:从246个国家在我目前的国家codebook, RegionInfo
是为他们提供了125,其余的(121)不支持。结论:这不是一个很好的方式得到一个国家codebook
From 246 countries in my current country codebook, RegionInfo
is available for 125 of them, the rest (121) are not supported. Conclusion: This is not a good way to get a country codebook.
这篇关于在.NET转换国家codeS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!