Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does Local.getCountry() return a UN M.49 3-digit code instead of an ISO 3166 2-letter code?

Tags:

java

android

The description of Local.getCountry() says:

Returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.

I wonder when is an ISO 3166 2-letter code returned and when a UN M.49 3-digit code ?

Example:

Locale locale = new Locale("de", "AT");
Log.i(TAG, "country code: " + locale.getCountry()); //returns "AT" which is an ISO 3166 2-letter code
like image 846
IIIIIIIIIIIIIIIIIIIIII Avatar asked Aug 12 '19 10:08

IIIIIIIIIIIIIIIIIIIIII


People also ask

How many countries are currently officially assigned a 3 digit ISO 3166 country codes?

The ISO 3166-1 standard currently comprises 249 countries, 193 of which are sovereign states that are members of the United Nations.

Are there 3 digit country codes?

ISO 3166-1 numeric (or numeric-3) codes are three-digit country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest.

How many ISO 2 country codes are there?

Each complete ISO 3166-2 code can then be used to uniquely identify a country subdivision in a global context. As of 3 March 2022 there are 5,048 codes defined in ISO 3166-2. For some countries, codes are defined for more than one level of subdivisions.


1 Answers

The return type depends on the country of the created Locale, thus it depends on how the Locale is created. The IANA specifies the country / region codes and supports UN M.49 and ISO 3166 2.

Locale.getCountry() returns the code specified by the IANA List, which is either ISO or UN. Search for "Type: region":

Example UN M.49:

Type: region
Subtag: 053
Description: Australia and New Zealand
Added: 2005-10-16
%%

Example Iso 3166 2:

Type: region
Subtag: VA
Description: Holy See (Vatican City State)
Added: 2005-10-16
%%

Source: https://developer.android.com/reference/java/util/Locale

like image 186
Meiswjn Avatar answered Oct 05 '22 03:10

Meiswjn