[英]Locale and ISO3CountryCodes
I have seen recently in java 1.7 that if I loop on Locales and get the ISO3Country code for the same then for Locale "CS" it gives me error "couldn't find 3 letter country code CS". 我最近在Java 1.7中看到,如果我在语言环境上循环并获得相同的ISO3Country代码,则对于语言环境“ CS”,它给我错误“找不到3个字母的国家代码CS”。 Is it expected behavior?
这是预期的行为吗? I also tested in java 1.6 but there I am not getting this error.
我也在Java 1.6中进行了测试,但没有收到此错误。
Locales[] locales = GregorianCalender.getAvailableLocales();
For(Locale l: locales){
System.out.println(l.getISO3CountryCode());
}
The short answer is: This is a country code for a country that no longer exists (Serbia and Montenegro), so the behavior may indeed be indeterminate. 简短的答案是:这是一个不再存在的国家(塞尔维亚和黑山)的国家代码,因此行为的确可能是不确定的。
ISO-3166 is divided into three parts. ISO-3166分为三个部分。 The first part, ISO-3166-1, defines these country codes and, in turn, has several parts.
第一部分,ISO-3166-1,定义了这些国家/地区代码,并且又分为几个部分。 The most relevant here are ISO-3166-1 alpha-2 and ISO-3166-1 alpha-3 which define the 2 and 3-letter country codes, respectively.
这里最相关的是ISO-3166-1 alpha-2和ISO-3166-1 alpha-3 ,它们分别定义了2个字母和3个字母的国家/地区代码。
According to the alpha-2 table, "CS" is the country code for Serbia and Montenegro, a country that no longer exists. 根据alpha-2表,“ CS”是塞尔维亚和黑山(不再存在的国家)的国家代码。 It still has an entry in alpha-2, marked as "reserved for deletion", for backwards compatibility purposes.
它仍然具有alpha-2条目,标记为“保留删除”,以实现向后兼容。 It is probably also still in Java for backwards compatibility.
为了向后兼容,它可能仍在Java中。
The equivalent entry in alpha-3 is "SCG" and is also be marked as reserved. alpha-3中的等效项是“ SCG”,也被标记为保留。 I would expect this code to be returned to you, but can understand why it might not be.
我希望此代码可以返回给您,但可以理解为什么可能不会。 (Alternatively, ISO-3166-3 defines country codes for countries that no longer exist; they are four letters long and maybe "CSXX" is what should be returned here...)
(或者, ISO-3166-3为不再存在的国家/地区定义了国家/地区代码;它们的长度为四个字母,也许应该在此处返回“ CSXX” ...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.