문제

According to the ISO 2 character codes uk = United Kingdom. But Locale.UK.getCountry() is returning GB. Am I missing something?

도움이 되었습니까?

해결책

According to this,

The getCountry() method returns the ISO 3166 two-letter abbreviation for the locale's region or country member.

The ISO 3166 two-letter abbreviation for the UK is indeed GB. uk is not part of the standard, but more of a historical accident:

The use of .uk rather than .gb for the top-level domain is due to its pre-existing use in the (now obsolete) JANET Name Registration Scheme in which the order of address components were reversed. .uk was made available in DNS to simplify the translation to and from these addresses. There were plans for eventual transition to .gb to accord with correct usage, but this never occurred; the use of .uk is now entrenched, and it is impossible to register a .gb domain.

Depending on your target use, you may need to replace .gb with .uk.

다른 팁

uk is there for compatibility reasons (a mistake in the past).

The correct id is gb.

The only place where gb remains standard is the domain names, but this is outside the scope of this question.

To minimize potential issues you could remap uk to gb.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top