ISO includes two- and three-character alphabetic codes and three-digit numeric codes that may be needed for activities involving exchange of data with international organizations that have adopted that standard. The 8th edition established trigraph codes for each country based upon the ISO alpha-3 character sets. These codes are used throughout NATO. Skip to main content Go to CIA. References Country Data Codes. Filter All.
Download Data. Previous Page Page 01 of 05 Next Page. American Samoa. Antigua and Barbuda. Ashmore and Cartier Islands. Bahamas, The. Baker Island. The practice was first mentioned in RFC October The ISO defines international standards for many areas of trade and industry, often after long and complicated negotiations. The ISO Standard defines Codes for the representation of names of countries and their subdivisions.
ISO consists of the following 3 parts:. These codes are used for a broad range of applications, for example but not limited to marking of freight containers, postal use and as a basis for standard currency codes.
For compatibility reasons, two non-conforming locales are treated as special cases. These are ill-formed in BCP 47 since the variants are too short. To ease migration to BCP 47, these are treated specially during construction. These two cases and only these cause a constructor to generate an extension, all other values behave exactly as they did prior to Java 7. This is now representable using a Unicode locale extension, by specifying the Unicode locale key ca for "calendar" and type japanese.
When the Locale constructor is called with the arguments "ja", "JP", "JP", the extension "u-ca-japanese" is automatically added. This is also now representable using a Unicode locale extension, by specifying the Unicode locale key nu for "number" and value thai. When the Locale constructor is called with the arguments "th", "TH", "TH", the extension "u-nu-thai" is automatically added. Locale's constructor has always converted three language codes to their earlier, obsoleted forms: he maps to iw , yi maps to ji , and id maps to in.
This continues to be the case, in order to not break backwards compatibility. The APIs added in 1. This preserves the equivalence between Locales no matter which code or API is used to construct them. Java's default resource bundle lookup mechanism also implements this mapping, so that resources can be named using either convention, see ResourceBundle.
The Locale constructors have always specified that the language and the country param be two characters in length, although in practice they have accepted any length. The specification has now been relaxed to allow language codes of two to eight characters and country region codes of two to three characters, and in particular, three-letter language codes and three-digit region codes as specified in the IANA Language Subtag Registry.
For compatibility, the implementation still does not impose a length constraint. Note: ISO is not a stable standard; some of the language codes it defines specifically "iw", "ji", and "in" have changed.
This constructor accepts both the old codes "iw", "ji", and "in" and the new codes "he", "yi", and "id" , but all other API on Locale will return only the OLD codes.
For backward compatibility reasons, this constructor does not make any syntactic checks on the input. The Java Virtual Machine sets the default locale during startup based on the host environment. It is used by many locale-sensitive methods if no locale is explicitly specified. It can be changed using the setDefault method. It can be changed using the setDefault Locale. Category, Locale method. If there is a security manager, its checkPermission method is called with a PropertyPermission "user.
Since changing the default locale may affect many different areas of functionality, this method should only be used if the caller is prepared to reinitialize locale-sensitive code running within the same Java Virtual Machine. By setting the default locale with this method, all of the default locales for each Category are also set to the specified default locale.
Therefore, the list returned by this method does not contain ALL valid codes that can be used to create Locales.
Note that this method does not return obsolete 2-letter country codes. IsoCountryCode type with type Locale. Note: ISO is not a stable standard— some languages' codes have changed. The list this function returns includes both the new and the old codes for the languages whose codes have changed.
The Locale class also supports language codes up to 8 characters in length. Locale's constructor recognizes both the new and the old codes for the languages whose codes have changed, but this function always returns the old code. If you want to check for a specific language whose code has changed, don't do if locale. Instead, do if locale.
When the locale has neither script nor extensions, the result is the same as in Java 6 and prior. If both the language and country fields are missing, this function will return the empty string, even if the variant, script, or extensions field is present you can't have a locale with just a variant, the variant must accompany a well-formed language or country code.
If script or extensions are present and variant is missing, no underscore is added before the " ". This behavior is designed to support debugging and to be compatible with previous uses of toString that expected language, country, and variant fields only.
To represent a Locale as a String for interchange purposes, use toLanguageTag. If this Locale has a language, country, or variant that does not satisfy the IETF BCP 47 language tag syntax requirements, this method handles these fields as described below:. Language: If language is empty, or not well-formed for example "a" or "e2" , it will be emitted as "und" Undetermined. Country: If country is not well-formed for example "12" or "USA" , it will be omitted. The first appended subtag will be "lvariant", followed by the sub-segments in order, separated by hyphen.
If the remainder is non-empty, it will be emitted as a private use subtag as above even if the remainder turns out to be well-formed. Special Conversions: Java supports some old locale representations, including deprecated ISO language codes, for compatibility.
This method performs the following conversions: Deprecated ISO language codes "iw", "ji", and "in" are converted to "he", "yi", and "id", respectively.
For example, new Locale "xx", "YY". If the specified language tag contains any ill-formed subtags, the first such subtag and all following subtags are ignored.
Compare to Locale. String which throws an exception in this case. The following conversions are performed: The language code "und" is mapped to language "". The language codes "he", "yi", and "id" are mapped to "iw", "ji", and "in" respectively. This is the same canonicalization that's done in Locale's constructors. The portion of a private use subtag prefixed by "lvariant", if any, is removed and appended to the variant field in the result locale without case normalization.
Language is normalized to lower case, script to title case, country to upper case, and extensions to lower case. This implements the 'Language-Tag' production of BCP47, and so supports legacy regular and irregular, referred to as "Type: grandfathered" in BCP47 as well as private use language tags.
Stand alone private use tags are represented as empty language and extension 'x-whatever', and legacy tags are converted to their canonical replacements where they exist. Legacy tags with canonical replacements are as follows: Legacy tags with canonical replacements legacy tag modern replacement art-lojban jbo i-ami ami i-bnn bnn i-hak hak i-klingon tlh i-lux lb i-navajo nv i-pwn pwn i-tao tao i-tay tay i-tsu tsu no-bok nb no-nyn nn sgn-BE-FR sfb sgn-BE-NL vgt sgn-CH-DE sgg zh-guoyu cmn zh-hakka hak zh-min-nan nan zh-xiang hsn.
Legacy tags with no modern replacement will be converted as follows: Legacy tags with no modern replacement legacy tag converts to cel-gaulish xtg-x-cel-gaulish en-GB-oed en-GB-x-oed i-default en-x-i-default i-enochian und-x-i-enochian i-mingo see-x-i-mingo zh-min nan-x-zh-min. Note : there is no guarantee that toLanguageTag and forLanguageTag will round-trip. Module java. Package java. Object java. Locale All Implemented Interfaces: Serializable , Cloneable public final class Locale extends Object implements Cloneable , Serializable A Locale object represents a specific geographical, political, or cultural region.
An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation— the number should be formatted according to the customs and conventions of the user's native country, region, or culture.
Note: BCP 47 only uses hyphen '-' as a delimiter, this is more lenient. Example: "polyton" Polytonic Greek , "POSIX" extensions A map from single character keys to string values, indicating extensions apart from language identification. The extensions in Locale implement the semantics and syntax of BCP 47 extension subtags and private use subtags. The extensions are case insensitive, but Locale canonicalizes all extension keys and values to lower case.
Note that extensions cannot have empty values. Well-formed keys are single characters from the set [a-zA-Z]. The Builder only checks if an individual field satisfies the syntactic requirement is well-formed , but does not validate the value itself. Builder for details. Creating a Locale There are several different ways to create a Locale object.
Builder Using Locale. Constructors The Locale class provides three constructors: Locale String language Locale String language, String country Locale String language, String country, String variant These constructors allow you to create a Locale object with language, country and variant, but you cannot specify script or extensions.
0コメント