1Locale::Codes::Country(U3s)er Contributed Perl DocumentatLioocnale::Codes::Country(3)
2
3
4
6 Locale::Codes::Country - standard codes for country identification
7
9 use Locale::Codes::Country;
10
11 $country = code2country('jp' [,CODESET]); # $country gets 'Japan'
12 $code = country2code('Norway' [,CODESET]); # $code gets 'no'
13
14 @codes = all_country_codes( [CODESET]);
15 @names = all_country_names();
16
17 # semi-private routines
18 Locale::Codes::Country::alias_code('uk' => 'gb');
19 Locale::Codes::Country::rename_country('gb' => 'Great Britain');
20
22 The "Locale::Codes::Country" module provides access to several code
23 sets that can be used for identifying countries, such as those defined
24 in ISO 3166-1.
25
26 Most of the routines take an optional additional argument which
27 specifies the code set to use. If not specified, the default ISO 3166-1
28 two-letter codes will be used.
29
31 There are several different code sets you can use for identifying
32 countries. A code set may be specified using either a name, or a
33 constant that is automatically exported by this module.
34
35 For example, the two are equivalent:
36
37 $country = code2country('jp','alpha-2');
38 $country = code2country('jp',LOCALE_CODE_ALPHA_2);
39
40 The codesets currently supported are:
41
42 alpha-2, LOCALE_CODE_ALPHA_2
43 This is the set of two-letter (lowercase) codes from ISO 3166-1,
44 such as 'tv' for Tuvalu.
45
46 This is the default code set.
47
48 alpha-3, LOCALE_CODE_ALPHA_3
49 This is the set of three-letter (lowercase) codes from ISO 3166-1,
50 such as 'brb' for Barbados. These codes are actually defined and
51 maintained by the U.N. Statistics division.
52
53 numeric, LOCALE_CODE_NUMERIC
54 This is the set of three-digit numeric codes from ISO 3166-1, such
55 as 064 for Bhutan. These codes are actually defined and maintained
56 by the U.N. Statistics division.
57
58 If a 2-digit code is entered, it is converted to 3 digits by
59 prepending a 0.
60
61 fips-10, LOCALE_CODE_FIPS
62 The FIPS 10 data are two-letter (uppercase) codes assigned by the
63 National Geospatial-Intelligence Agency.
64
65 NOTE: The FIPS-10 document is being withdrawn. It was deprecated
66 in 2008, and is being updated now only until all the agencies that
67 use it have switched to something else.
68
69 I will continue to support the FIPS-10 codeset as long as it is
70 available, but at the point it is no longer available, support will
71 be withdrawn immediately. If an official end-of-life date is
72 announced, I will include a notice here. Otherwise, support for
73 the codeset will be discontinued when the document is withdrawn.
74
75 You are encouraged to no longer use the FIPS-10 codeset.
76
77 dom, LOCALE_CODE_DOM
78 The IANA is responsible for delegating management of the top level
79 country domains. The country domains are the two-letter
80 (lowercase) codes from ISO 3166 with a few other additions.
81
83 code2country ( CODE [,CODESET] )
84 country2code ( NAME [,CODESET] )
85 country_code2code ( CODE ,CODESET ,CODESET2 )
86 all_country_codes ( [CODESET] )
87 all_country_names ( [CODESET] )
88 Locale::Codes::Country::rename_country ( CODE ,NEW_NAME [,CODESET] )
89 Locale::Codes::Country::add_country ( CODE ,NAME [,CODESET] )
90 Locale::Codes::Country::delete_country ( CODE [,CODESET] )
91 Locale::Codes::Country::add_country_alias ( NAME ,NEW_NAME )
92 Locale::Codes::Country::delete_country_alias ( NAME )
93 Locale::Codes::Country::rename_country_code ( CODE ,NEW_CODE
94 [,CODESET] )
95 Locale::Codes::Country::add_country_code_alias ( CODE ,NEW_CODE
96 [,CODESET] )
97 Locale::Codes::Country::delete_country_code_alias ( CODE [,CODESET] )
98 These routines are all documented in the Locale::Codes::API man
99 page.
100
101 alias_code ( ALIAS, CODE [,CODESET] )
102 Version 2.07 included 2 functions for modifying the internal data:
103 rename_country and alias_code. Both of these could be used only to
104 modify the internal data for country codes.
105
106 As of 3.10, the internal data for all types of codes can be
107 modified.
108
109 The alias_code function is preserved for backwards compatibility,
110 but the following two are identical:
111
112 alias_code(ALIAS,CODE [,CODESET]);
113 rename_country_code(CODE,ALIAS [,CODESET]);
114
115 and the latter should be used for consistency.
116
117 The alias_code function is deprecated and will be removed at some
118 point in the future.
119
120 Note: this function was previously called _alias_code, but the
121 leading underscore has been dropped. The old name was supported for
122 all 2.X releases, but has been dropped as of 3.00.
123
125 Locale::Codes
126 The Locale-Codes distribution.
127
128 Locale::Codes::API
129 The list of functions supported by this module.
130
131 Locale::SubCountry
132 ISO codes for country sub-divisions (states, counties, provinces,
133 etc), as defined in ISO 3166-2. This module is not part of the
134 Locale-Codes distribution, but is available from CPAN in
135 CPAN/modules/by-module/Locale/
136
137 http://www.iso.org/iso/country_codes
138 Official home page for the ISO 3166 maintenance agency.
139
140 Unfortunately, they do not make the actual ISO available for free,
141 so I cannot check the alpha-3 and numerical codes here.
142
143 http://www.iso.org/iso/list-en1-semic-3.txt
144 http://www.iso.org/iso/home/standards/country_codes/iso-3166-1_decoding_table.htm
145 The source of ISO 3166-1 two-letter codes used by this module.
146
147 http://unstats.un.org/unsd/methods/m49/m49alpha.htm
148 The source of the official ISO 3166-1 three-letter codes and three-
149 digit codes.
150
151 For some reason, this table is incomplete! Several countries are
152 missing from it, and I cannot find them anywhere on the UN site. I
153 get as much of the data from here as I can.
154
155 http://earth-info.nga.mil/gns/html/gazetteers2.html
156 The official list of the FIPS 10 codes.
157
158 http://www.iana.org/domains/
159 Official source of the top-level domain names.
160
161 https://www.cia.gov/library/publications/the-world-factbook/appendix/print_appendix-d.html
162 The World Factbook maintained by the CIA is a potential source of
163 the data. Unfortunately, it adds/preserves non-standard codes, so
164 it is no longer used as a source of data.
165
166 http://www.statoids.com/wab.html
167 Another unofficial source of data. Currently, it is not used to get
168 data, but the notes and explanatory material were very useful for
169 understanding discrepancies between the sources.
170
172 See Locale::Codes for full author history.
173
174 Currently maintained by Sullivan Beck (sbeck@cpan.org).
175
177 Copyright (c) 1997-2001 Canon Research Centre Europe (CRE).
178 Copyright (c) 2001-2010 Neil Bowers
179 Copyright (c) 2010-2013 Sullivan Beck
180
181 This module is free software; you can redistribute it and/or modify it
182 under the same terms as Perl itself.
183
184
185
186perl v5.16.3 2013-04-12 Locale::Codes::Country(3)