Locale::Codes::Types(3perl) | Perl Programmers Reference Guide | Locale::Codes::Types(3perl) |
Locale::Codes::Types - types of data sets supported
This document contains a description of different types of code sets supported by the Locale-Codes distribution.
The following types are supported:
Any time you have to specify the type of data, use one of the values from this list. When using the OO interface, you have to specify the type of data you are working with. For example:
use Locale::Codes; ... $obj->type('country'); $obj->type('langext');
When using the traditional interfaces, the functions all have the data type included in the function name. For example:
use Locale::Codes::Country; code2country(...); use Locale::Codes::LangExt; code2langext(...);
Each type of data may have any number of code sets. Code sets may be specified by name. Traditionally, a perl constant was exported and could also be used to specify the code set.
Both methods are available for both the OO and traditional interfaces, so whenever a function or method takes an argument specifying a code set, either the name or a constant can be used.
In the lists below, a code set is specified in the list by including the name and the constant. So, for example, the first country code set is named 'alpha-2' and has a perl constant "LOCALE_COUNTRY_ALPHA_2" associated with it. When using the OO interface, the constants are only available if you import them by loading the module with:
use Locale::Codes ':constants';
The constants are always available when using the traditional interfaces.
Some of the older perl constants names were not consistent, and in those cases, two constants are available (a newer consistent name and the older inconsistent one). Either may be used.
The default code set for each type is marked with an asterisk (*).
Code sets for identifying countries are maintained by several different agencies and standards.
The following code sets are maintained in the ISO 3166 standard. The official home page for the ISO 3166 maintenance agency is: <http://www.iso.org/iso/home/standards/country_codes.htm> .
Only the officially assigned codes are included.
If a 2-digit code is entered, it is converted to 3 digits by prepending a 0.
A list of domain names are maintained by the IANA (Internet Assigned Numbers Authority). These are available at: <http://www.iana.org/domains/root/db/> . Only the actual country codes are used, and the country names come from ISO 3166.
The United Nations also maintains country lists. Their list is also similar, but not identical, to the ISO 3166 list.
The data is available here: <https://unstats.un.org/unsd/methodology/m49/>
Previously, this table was treated as a source of the ISO 3166 data, but I found that the table was incomplete, so I stopped using it. Later, it was added back in as it's own list of codes.
The US Government also keeps a list of codes. Originally, it maintained the FIPS-11 code set, but this was deprecated and replaced by the GENC code set. The FIPS-11 code sets are no longer supported by Locale-Codes.
The GENC code sets are available here: <https://nsgreg.nga.mil/genc/discovery> . They are also similar, but not identical, to the ISO 3166 code sets.
There are other sources of codes that are not currently used in this distribution.
ISO codes for country sub-divisions (states, counties, provinces, etc), as defined in ISO 3166-2. This module is not part of the Locale-Codes distribution, but is available from CPAN in CPAN/modules/by-module/Locale/
The World Factbook maintained by the CIA is a potential source of the data. Unfortunately, it adds/preserves non-standard codes, so it is not used as a source of data. <https://www.cia.gov/library/publications/the-world-factbook/appendix/print_appendix-d.html>
Another unofficial source of data is the Statoids web site: <http://www.statoids.com/wab.html> . Currently, it is not used to get data, but the notes and explanatory material were very useful for understanding discrepancies between the sources.
Code sets for identifying languages come from a couple different locations.
The primary source is ISO 639 . The ISO 639-2 codes are available here: <http://www.loc.gov/standards/iso639-2/> and the ISO 639-5 codes are available here: <http://www.loc.gov/standards/iso639-5/> .
In addition, the IANA maintains a language registry which are added to the ISO lists. Because it is intended to supplement the ISO standard, the IANA list is not separate.
The IANA data is available here: <http://www.iana.org/assignments/language-subtag-registry>
The code sets are:
The source of currency codes is the ISO 4217 data available here: <http://www.iso.org/iso/support/currency_codes_list-1.htm>
The code sets are:
Two of the codes specified by the standard (XTS which is reserved for testing purposes and XXX which is for transactions where no currency is involved) are omitted.
The source of script code sets is ISO 15924 available here: <http://www.unicode.org/iso15924/>
Additional data comes from the IANA language subtag registry: <http://www.iana.org/assignments/language-subtag-registry> .
Code sets are:
The Zxxx, Zyyy, and Zzzz codes are not used.
Language families are specified using codes from ISO 639-5 available here: <http://www.loc.gov/standards/iso639-5/id.php>
Code sets are:
Language variations are specified using codes from he IANA language subtag registry available here: <http://www.iana.org/assignments/language-subtag-registry>
Code sets are:
Language extensions are specified using codes from he IANA language subtag registry available here: <http://www.iana.org/assignments/language-subtag-registry>
Code sets are:
I'm always open to suggestions for new code sets.
In order for me to add a code set, I want the following criteria to be met:
Ideally, I'd only get data from an official source, but sometimes that is not possible. For example the ISO standards are not typically available for free, so I may have to get some of that data from alternate sources that I'm confident are getting their data from the official source. However, I will always be hesitant to accept a non-official source.
As an example, I used to get some country data from the CIA World Factbook. Given the nature of the source, I'm sure they're updating data from the official sources and I consider it "nearly" official. However, even in this case, I found that they were adding codes that were not part of the standard, so I have stopped using them as a source.
There are many 3rd party sites which maintain lists (many of which are actually in a more convenient form than the official sites). Unfortunately, I will reject most of them since I have no feel for how "official" they are.
I am also reluctant to accept data sent to me by an individual. Although I appreciate the offer, it is simply not practical to consider an individual contribution as a reliable source of data. The source should be an official agency of some sort.
These requirements are open to discussion. If you have a code set you'd like to see added, but which may not meet all of the above requirements, feel free to email me and we'll discuss it. Depending on circumstances, I may be willing to waive some of these criteria.
See Locale::Codes for full author history.
Currently maintained by Sullivan Beck (sbeck@cpan.org).
Copyright (c) 1997-2001 Canon Research Centre Europe (CRE). Copyright (c) 2001-2010 Neil Bowers Copyright (c) 2010-2018 Sullivan Beck
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2020-07-21 | perl v5.28.1 |