1Locale::Country(3) User Contributed Perl Documentation Locale::Country(3)
2
3
4
6 Locale::Country - standard codes for country identification
7
9 use Locale::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::Country::alias_code('uk' => 'gb');
19 Locale::Country::rename_country('gb' => 'Great Britain');
20
22 The "Locale::Country" module provides access to several code sets that
23 can be used for identifying countries, such as those defined in ISO
24 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::Country::rename_country ( CODE ,NEW_NAME [,CODESET] )
89 Locale::Country::add_country ( CODE ,NAME [,CODESET] )
90 Locale::Country::delete_country ( CODE [,CODESET] )
91 Locale::Country::add_country_alias ( NAME ,NEW_NAME )
92 Locale::Country::delete_country_alias ( NAME )
93 Locale::Country::rename_country_code ( CODE ,NEW_CODE [,CODESET] )
94 Locale::Country::add_country_code_alias ( CODE ,NEW_CODE [,CODESET] )
95 Locale::Country::delete_country_code_alias ( CODE [,CODESET] )
96 These routines are all documented in the Locale::Codes::API man
97 page.
98
99 alias_code ( ALIAS, CODE [,CODESET] )
100 Version 2.07 included 2 functions for modifying the internal data:
101 rename_country and alias_code. Both of these could be used only to
102 modify the internal data for country codes.
103
104 As of 3.10, the internal data for all types of codes can be
105 modified.
106
107 The alias_code function is preserved for backwards compatibility,
108 but the following two are identical:
109
110 alias_code(ALIAS,CODE [,CODESET]);
111 rename_country_code(CODE,ALIAS [,CODESET]);
112
113 and the latter should be used for consistency.
114
115 The alias_code function is deprecated and will be removed at some
116 point in the future.
117
118 Note: this function was previously called _alias_code, but the
119 leading underscore has been dropped. The old name was supported for
120 all 2.X releases, but has been dropped as of 3.00.
121
123 Locale::Codes
124 The Locale-Codes distribution.
125
126 Locale::Codes::API
127 The list of functions supported by this module.
128
129 Locale::SubCountry
130 ISO codes for country sub-divisions (states, counties, provinces,
131 etc), as defined in ISO 3166-2. This module is not part of the
132 Locale-Codes distribution, but is available from CPAN in
133 CPAN/modules/by-module/Locale/
134
135 http://www.iso.org/iso/country_codes
136 Official home page for the ISO 3166 maintenance agency.
137
138 Unfortunately, they do not make the actual ISO available for free,
139 so I cannot check the alpha-3 and numerical codes here.
140
141 http://www.iso.org/iso/list-en1-semic-3.txt
142 http://www.iso.org/iso/home/standards/country_codes/iso-3166-1_decoding_table.htm
143 The source of ISO 3166-1 two-letter codes used by this module.
144
145 http://unstats.un.org/unsd/methods/m49/m49alpha.htm
146 The source of the official ISO 3166-1 three-letter codes and three-
147 digit codes.
148
149 For some reason, this table is incomplete! Several countries are
150 missing from it, and I cannot find them anywhere on the UN site. I
151 get as much of the data from here as I can.
152
153 http://earth-info.nga.mil/gns/html/gazetteers2.html
154 The official list of the FIPS 10 codes.
155
156 http://www.iana.org/domains/
157 Official source of the top-level domain names.
158
159 https://www.cia.gov/library/publications/the-world-factbook/appendix/print_appendix-d.html
160 The World Factbook maintained by the CIA is a potential source of
161 the data. Unfortunately, it adds/preserves non-standard codes, so
162 it is no longer used as a source of data.
163
164 http://www.statoids.com/wab.html
165 Another unofficial source of data. Currently, it is not used to get
166 data, but the notes and explanatory material were very useful for
167 understanding discrepancies between the sources.
168
170 See Locale::Codes for full author history.
171
172 Currently maintained by Sullivan Beck (sbeck@cpan.org).
173
175 Copyright (c) 1997-2001 Canon Research Centre Europe (CRE).
176 Copyright (c) 2001-2010 Neil Bowers
177 Copyright (c) 2010-2013 Sullivan Beck
178
179 This module is free software; you can redistribute it and/or modify it
180 under the same terms as Perl itself.
181
182
183
184perl v5.16.3 2013-06-03 Locale::Country(3)