Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "Locale::Country 3" | |
132 | .TH Locale::Country 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | Locale::Country \- ISO codes for country identification (ISO 3166) | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 1 | |
138 | \& use Locale::Country; | |
139 | .Ve | |
140 | .PP | |
141 | .Vb 2 | |
142 | \& $country = code2country('jp'); # $country gets 'Japan' | |
143 | \& $code = country2code('Norway'); # $code gets 'no' | |
144 | .Ve | |
145 | .PP | |
146 | .Vb 2 | |
147 | \& @codes = all_country_codes(); | |
148 | \& @names = all_country_names(); | |
149 | .Ve | |
150 | .PP | |
151 | .Vb 3 | |
152 | \& # semi-private routines | |
153 | \& Locale::Country::alias_code('uk' => 'gb'); | |
154 | \& Locale::Country::rename_country('gb' => 'Great Britain'); | |
155 | .Ve | |
156 | .SH "DESCRIPTION" | |
157 | .IX Header "DESCRIPTION" | |
158 | The \f(CW\*(C`Locale::Country\*(C'\fR module provides access to the \s-1ISO\s0 | |
159 | codes for identifying countries, as defined in \s-1ISO\s0 3166\-1. | |
160 | You can either access the codes via the \*(L"conversion routines\*(R" | |
161 | (described below), or with the two functions which return lists | |
162 | of all country codes or all country names. | |
163 | .PP | |
164 | There are three different code sets you can use for identifying | |
165 | countries: | |
166 | .IP "\fBalpha\-2\fR" 4 | |
167 | .IX Item "alpha-2" | |
168 | Two letter codes, such as 'tv' for Tuvalu. | |
169 | This code set is identified with the symbol \f(CW\*(C`LOCALE_CODE_ALPHA_2\*(C'\fR. | |
170 | .IP "\fBalpha\-3\fR" 4 | |
171 | .IX Item "alpha-3" | |
172 | Three letter codes, such as 'brb' for Barbados. | |
173 | This code set is identified with the symbol \f(CW\*(C`LOCALE_CODE_ALPHA_3\*(C'\fR. | |
174 | .IP "\fBnumeric\fR" 4 | |
175 | .IX Item "numeric" | |
176 | Numeric codes, such as 064 for Bhutan. | |
177 | This code set is identified with the symbol \f(CW\*(C`LOCALE_CODE_NUMERIC\*(C'\fR. | |
178 | .PP | |
179 | All of the routines take an optional additional argument | |
180 | which specifies the code set to use. | |
181 | If not specified, it defaults to the two-letter codes. | |
182 | This is partly for backwards compatibility (previous versions | |
183 | of this module only supported the alpha\-2 codes), and | |
184 | partly because they are the most widely used codes. | |
185 | .PP | |
186 | The alpha\-2 and alpha\-3 codes are not case\-dependent, | |
187 | so you can use '\s-1BO\s0', 'Bo', 'bO' or 'bo' for Bolivia. | |
188 | When a code is returned by one of the functions in | |
189 | this module, it will always be lower\-case. | |
190 | .PP | |
191 | As of version 2.00, Locale::Country supports variant | |
192 | names for countries. So, for example, the country code for \*(L"United States\*(R" | |
193 | is \*(L"us\*(R", so country2code('United States') returns 'us'. | |
194 | Now the following will also return 'us': | |
195 | .PP | |
196 | .Vb 2 | |
197 | \& country2code('United States of America') | |
198 | \& country2code('USA') | |
199 | .Ve | |
200 | .SH "CONVERSION ROUTINES" | |
201 | .IX Header "CONVERSION ROUTINES" | |
202 | There are three conversion routines: \f(CW\*(C`code2country()\*(C'\fR, \f(CW\*(C`country2code()\*(C'\fR, | |
203 | and \f(CW\*(C`country_code2code()\*(C'\fR. | |
204 | .IP "code2country( \s-1CODE\s0, [ \s-1CODESET\s0 ] )" 4 | |
205 | .IX Item "code2country( CODE, [ CODESET ] )" | |
206 | This function takes a country code and returns a string | |
207 | which contains the name of the country identified. | |
208 | If the code is not a valid country code, as defined by \s-1ISO\s0 3166, | |
209 | then \f(CW\*(C`undef\*(C'\fR will be returned: | |
210 | .Sp | |
211 | .Vb 1 | |
212 | \& $country = code2country('fi'); | |
213 | .Ve | |
214 | .IP "country2code( \s-1STRING\s0, [ \s-1CODESET\s0 ] )" 4 | |
215 | .IX Item "country2code( STRING, [ CODESET ] )" | |
216 | This function takes a country name and returns the corresponding | |
217 | country code, if such exists. | |
218 | If the argument could not be identified as a country name, | |
219 | then \f(CW\*(C`undef\*(C'\fR will be returned: | |
220 | .Sp | |
221 | .Vb 2 | |
222 | \& $code = country2code('Norway', LOCALE_CODE_ALPHA_3); | |
223 | \& # $code will now be 'nor' | |
224 | .Ve | |
225 | .Sp | |
226 | The case of the country name is not important. | |
227 | See the section \*(L"\s-1KNOWN\s0 \s-1BUGS\s0 \s-1AND\s0 \s-1LIMITATIONS\s0\*(R" below. | |
228 | .IP "country_code2code( \s-1CODE\s0, \s-1CODESET\s0, \s-1CODESET\s0 )" 4 | |
229 | .IX Item "country_code2code( CODE, CODESET, CODESET )" | |
230 | This function takes a country code from one code set, | |
231 | and returns the corresponding code from another code set. | |
232 | .Sp | |
233 | .Vb 3 | |
234 | \& $alpha2 = country_code2code('fin', | |
235 | \& LOCALE_CODE_ALPHA_3, LOCALE_CODE_ALPHA_2); | |
236 | \& # $alpha2 will now be 'fi' | |
237 | .Ve | |
238 | .Sp | |
239 | If the code passed is not a valid country code in | |
240 | the first code set, or if there isn't a code for the | |
241 | corresponding country in the second code set, | |
242 | then \f(CW\*(C`undef\*(C'\fR will be returned. | |
243 | .SH "QUERY ROUTINES" | |
244 | .IX Header "QUERY ROUTINES" | |
245 | There are two function which can be used to obtain a list of all codes, | |
246 | or all country names: | |
247 | .ie n .IP """all_country_codes( [ CODESET ] )""" 4 | |
248 | .el .IP "\f(CWall_country_codes( [ CODESET ] )\fR" 4 | |
249 | .IX Item "all_country_codes( [ CODESET ] )" | |
250 | Returns a list of all two-letter country codes. | |
251 | The codes are guaranteed to be all lower\-case, | |
252 | and not in any particular order. | |
253 | .ie n .IP """all_country_names( [ CODESET ] )""" 4 | |
254 | .el .IP "\f(CWall_country_names( [ CODESET ] )\fR" 4 | |
255 | .IX Item "all_country_names( [ CODESET ] )" | |
256 | Returns a list of all country names for which there is a corresponding | |
257 | country code in the specified code set. | |
258 | The names are capitalised, and not returned in any particular order. | |
259 | .Sp | |
260 | Not all countries have alpha\-3 and numeric codes \- | |
261 | some just have an alpha\-2 code, | |
262 | so you'll get a different number of countries | |
263 | depending on which code set you specify. | |
264 | .SH "SEMI-PRIVATE ROUTINES" | |
265 | .IX Header "SEMI-PRIVATE ROUTINES" | |
266 | Locale::Country provides two semi-private routines for modifying | |
267 | the internal data. | |
268 | Given their status, they aren't exported by default, | |
269 | and so need to be called by prefixing the function name with the | |
270 | package name. | |
271 | .Sh "alias_code" | |
272 | .IX Subsection "alias_code" | |
273 | Define a new code as an alias for an existing code: | |
274 | .PP | |
275 | .Vb 1 | |
276 | \& Locale::Country::alias_code( ALIAS => CODE [, CODESET ] ) | |
277 | .Ve | |
278 | .PP | |
279 | This feature was added as a mechanism for handling | |
280 | a \*(L"uk\*(R" code. The \s-1ISO\s0 standard says that the two-letter code for | |
281 | \&\*(L"United Kingdom\*(R" is \*(L"gb\*(R", whereas domain names are all .uk. | |
282 | .PP | |
283 | By default the module does not understand \*(L"uk\*(R", since it is implementing | |
284 | an \s-1ISO\s0 standard. If you would like 'uk' to work as the two-letter | |
285 | code for United Kingdom, use the following: | |
286 | .PP | |
287 | .Vb 1 | |
288 | \& Locale::Country::alias_code('uk' => 'gb'); | |
289 | .Ve | |
290 | .PP | |
291 | With this code, both \*(L"uk\*(R" and \*(L"gb\*(R" are valid codes for United Kingdom, | |
292 | with the reverse lookup returning \*(L"uk\*(R" rather than the usual \*(L"gb\*(R". | |
293 | .PP | |
294 | \&\fBNote:\fR this function was previously called _alias_code, | |
295 | but the leading underscore has been dropped. | |
296 | The old name will be supported for all 2.X releases for | |
297 | backwards compatibility. | |
298 | .Sh "rename_country" | |
299 | .IX Subsection "rename_country" | |
300 | If the official country name just isn't good enough for you, | |
301 | you can rename a country. For example, the official country | |
302 | name for code 'gb' is 'United Kingdom'. | |
303 | If you want to change that, you might call: | |
304 | .PP | |
305 | .Vb 1 | |
306 | \& Locale::Country::rename_country('gb' => 'Great Britain'); | |
307 | .Ve | |
308 | .PP | |
309 | This means that calling code2country('gb') will now return | |
310 | \&'Great Britain' instead of 'United Kingdom'. | |
311 | The original country name is retained as an alias, | |
312 | so for the above example, country2code('United Kingdom') | |
313 | will still return 'gb'. | |
314 | .SH "EXAMPLES" | |
315 | .IX Header "EXAMPLES" | |
316 | The following example illustrates use of the \f(CW\*(C`code2country()\*(C'\fR function. | |
317 | The user is prompted for a country code, and then told the corresponding | |
318 | country name: | |
319 | .PP | |
320 | .Vb 1 | |
321 | \& $| = 1; # turn off buffering | |
322 | .Ve | |
323 | .PP | |
324 | .Vb 11 | |
325 | \& print "Enter country code: "; | |
326 | \& chop($code = <STDIN>); | |
327 | \& $country = code2country($code, LOCALE_CODE_ALPHA_2); | |
328 | \& if (defined $country) | |
329 | \& { | |
330 | \& print "$code = $country\en"; | |
331 | \& } | |
332 | \& else | |
333 | \& { | |
334 | \& print "'$code' is not a valid country code!\en"; | |
335 | \& } | |
336 | .Ve | |
337 | .SH "DOMAIN NAMES" | |
338 | .IX Header "DOMAIN NAMES" | |
339 | Most top-level domain names are based on these codes, | |
340 | but there are certain codes which aren't. | |
341 | If you are using this module to identify country from hostname, | |
342 | your best bet is to preprocess the country code. | |
343 | .PP | |
344 | For example, \fBedu\fR, \fBcom\fR, \fBgov\fR and friends would map to \fBus\fR; | |
345 | \&\fBuk\fR would map to \fBgb\fR. Any others? | |
346 | .SH "KNOWN BUGS AND LIMITATIONS" | |
347 | .IX Header "KNOWN BUGS AND LIMITATIONS" | |
348 | .IP "\(bu" 4 | |
349 | When using \f(CW\*(C`country2code()\*(C'\fR, the country name must currently appear | |
350 | exactly as it does in the source of the module. The module now supports | |
351 | a small number of variants. | |
352 | .Sp | |
353 | Possible extensions to this are: an interface for getting at the | |
354 | list of variant names, and regular expression matches. | |
355 | .IP "\(bu" 4 | |
356 | In the current implementation, all data is read in when the | |
357 | module is loaded, and then held in memory. | |
358 | A lazy implementation would be more memory friendly. | |
359 | .IP "\(bu" 4 | |
360 | Support for country names in different languages. | |
361 | .SH "SEE ALSO" | |
362 | .IX Header "SEE ALSO" | |
363 | .IP "Locale::Language" 4 | |
364 | .IX Item "Locale::Language" | |
365 | \&\s-1ISO\s0 two letter codes for identification of language (\s-1ISO\s0 639). | |
366 | .IP "Locale::Script" 4 | |
367 | .IX Item "Locale::Script" | |
368 | \&\s-1ISO\s0 codes for identification of scripts (\s-1ISO\s0 15924). | |
369 | .IP "Locale::Currency" 4 | |
370 | .IX Item "Locale::Currency" | |
371 | \&\s-1ISO\s0 three letter codes for identification of currencies | |
372 | and funds (\s-1ISO\s0 4217). | |
373 | .IP "Locale::SubCountry" 4 | |
374 | .IX Item "Locale::SubCountry" | |
375 | \&\s-1ISO\s0 codes for country sub-divisions (states, counties, provinces, etc), | |
376 | as defined in \s-1ISO\s0 3166\-2. | |
377 | This module is not part of the Locale-Codes distribution, | |
378 | but is available from \s-1CPAN\s0 in CPAN/modules/by\-module/Locale/ | |
379 | .IP "\s-1ISO\s0 3166\-1" 4 | |
380 | .IX Item "ISO 3166-1" | |
381 | The \s-1ISO\s0 standard which defines these codes. | |
382 | .IP "http://www.iso.org/iso/en/prods\-services/iso3166ma/index.html" 4 | |
383 | .IX Item "http://www.iso.org/iso/en/prods-services/iso3166ma/index.html" | |
384 | Official home page for the \s-1ISO\s0 3166 maintenance agency. | |
385 | .IP "http://www.egt.ie/standards/iso3166/iso3166\-1\-en.html" 4 | |
386 | .IX Item "http://www.egt.ie/standards/iso3166/iso3166-1-en.html" | |
387 | Another useful, but not official, home page. | |
388 | .IP "http://www.cia.gov/cia/publications/factbook/docs/app\-d\-1.html" 4 | |
389 | .IX Item "http://www.cia.gov/cia/publications/factbook/docs/app-d-1.html" | |
390 | An appendix in the \s-1CIA\s0 world fact book which lists country codes | |
391 | as defined by \s-1ISO\s0 3166, \s-1FIPS\s0 10\-4, and internet domain names. | |
392 | .SH "AUTHOR" | |
393 | .IX Header "AUTHOR" | |
394 | Neil Bowers <neil@bowers.com> | |
395 | .SH "COPYRIGHT" | |
396 | .IX Header "COPYRIGHT" | |
397 | Copyright (C) 2002\-2004, Neil Bowers. | |
398 | .PP | |
399 | Copyright (c) 1997\-2001 Canon Research Centre Europe (\s-1CRE\s0). | |
400 | .PP | |
401 | This module is free software; you can redistribute it and/or | |
402 | modify it under the same terms as Perl itself. |