~ubuntu-branches/ubuntu/intrepid/perl-doc-html/intrepid

« back to all changes in this revision

Viewing changes to Locale/Country.html

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2008-05-17 20:14:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080517201419-qgbuogq2ckkdisyi
Tags: 5.10.0-2
Supersede botched upload of 5.10.0-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
      <h2>Links:</h2>
55
55
      <ul>
56
56
        <li><a href="http://search.cpan.org">CPAN</a></li>
 
57
        <li><a href="http://www.perl.org">Perl.org</a></li>
57
58
        <li><a href="http://www.perl.com">Perl.com</a></li>
58
 
        <li><a href="http://www.perl.org">Perl.org</a></li>
 
59
        <li><a href="http://perlbuzz.com">Perl Buzz</a></li>
 
60
        <li><a href="http://www.perlfoundation.org/perl5/index.cgi">Perl 5 Wiki</a></li>
 
61
        <li><a href="http://jobs.perl.org">Perl Jobs</a></li>
59
62
        <li><a href="http://www.pm.org">Perl Mongers</a></li>
60
63
        <li><a href="http://www.perlmonks.org">Perl Monks</a></li>
61
64
        <li><a href="http://planet.perl.org">Planet Perl</a></li>
65
68
      <ul>
66
69
        <li>Site maintained by<br><a href="http://perl.jonallen.info">Jon Allen</a>
67
70
            (<a href="http://perl.jonallen.info">JJ</a>)</li>
68
 
        <li class="spaced">Last updated on<br>23 April 2006</li>
 
71
        <li class="spaced">Last updated on<br>23 December 2007</li>
69
72
        <li class="spaced">See the <a href="http://perl.jonallen.info/projects/perldoc">project page</a> for
70
73
        more details</li>
71
74
      </ul>
76
79
    <div id="centerContent">
77
80
      <div id="contentHeader">
78
81
        <div id="contentHeaderLeft"><a href="#" onClick="showLeft()">Show navigation</a></div>
79
 
        <div id="contentHeaderCentre">-- Perl 5.8.8 documentation --</div>
 
82
        <div id="contentHeaderCentre">-- Perl 5.10.0 documentation --</div>
80
83
        <div id="contentHeaderRight"><a href="#" onClick="showRight()">Show toolbar</a></div>
81
84
      </div>
82
85
      <div id="breadCrumbs"><a href="../index.html">Home</a> &gt; <a href="../index-modules-A.html">Core modules</a> &gt; <a href="../index-modules-L.html">L</a> &gt; Locale::Country</div>
83
86
      <script language="JavaScript">fromSearch();</script>
84
87
      <div id="contentBody"><div class="title_container"><div class="page_title">Locale::Country</div></div><ul><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#CONVERSION-ROUTINES">CONVERSION ROUTINES</a><li><a href="#QUERY-ROUTINES">QUERY ROUTINES</a><li><a href="#SEMI-PRIVATE-ROUTINES">SEMI-PRIVATE ROUTINES</a><ul><li><a href="#alias_code">alias_code</a><li><a href="#rename_country">rename_country</a></ul><li><a href="#EXAMPLES">EXAMPLES</a><li><a href="#DOMAIN-NAMES">DOMAIN NAMES</a><li><a href="#KNOWN-BUGS-AND-LIMITATIONS">KNOWN BUGS AND LIMITATIONS</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#AUTHOR">AUTHOR</a><li><a href="#COPYRIGHT">COPYRIGHT</a></ul><a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
85
 
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <a class="l_w" href="../Locale/Country.html">Locale::Country</a><span class="sc">;</span>
86
 
    
87
 
    <span class="i">$country</span> = <span class="i">code2country</span><span class="s">(</span><span class="q">&#39;jp&#39;</span><span class="s">)</span><span class="sc">;</span>        <span class="c"># $country gets &#39;Japan&#39;</span>
88
 
    <span class="i">$code</span>    = <span class="i">country2code</span><span class="s">(</span><span class="q">&#39;Norway&#39;</span><span class="s">)</span><span class="sc">;</span>    <span class="c"># $code gets &#39;no&#39;</span>
89
 
    
90
 
    <span class="i">@codes</span>   = <span class="i">all_country_codes</span><span class="s">(</span><span class="s">)</span><span class="sc">;</span>
91
 
    <span class="i">@names</span>   = <span class="i">all_country_names</span><span class="s">(</span><span class="s">)</span><span class="sc">;</span>
92
 
    
93
 
    <span class="c"># semi-private routines</span>
 
88
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <span class="w">Locale::Country</span><span class="sc">;</span></pre>
 
89
<pre class="verbatim">    <span class="i">$country</span> = <span class="i">code2country</span><span class="s">(</span><span class="q">&#39;jp&#39;</span><span class="s">)</span><span class="sc">;</span>        <span class="c"># $country gets &#39;Japan&#39;</span>
 
90
    <span class="i">$code</span>    = <span class="i">country2code</span><span class="s">(</span><span class="q">&#39;Norway&#39;</span><span class="s">)</span><span class="sc">;</span>    <span class="c"># $code gets &#39;no&#39;</span></pre>
 
91
<pre class="verbatim">    <span class="i">@codes</span>   = <span class="i">all_country_codes</span><span class="s">(</span><span class="s">)</span><span class="sc">;</span>
 
92
    <span class="i">@names</span>   = <span class="i">all_country_names</span><span class="s">(</span><span class="s">)</span><span class="sc">;</span></pre>
 
93
<pre class="verbatim">    <span class="c"># semi-private routines</span>
94
94
    <span class="i">Locale::Country::alias_code</span><span class="s">(</span><span class="q">&#39;uk&#39;</span> <span class="cm">=&gt;</span> <span class="q">&#39;gb&#39;</span><span class="s">)</span><span class="sc">;</span>
95
95
    <span class="i">Locale::Country::rename_country</span><span class="s">(</span><span class="q">&#39;gb&#39;</span> <span class="cm">=&gt;</span> <span class="q">&#39;Great Britain&#39;</span><span class="s">)</span><span class="sc">;</span></pre>
96
96
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
97
 
<p>The <code class="inline"><a class="l_w" href="../Locale/Country.html">Locale::Country</a></code> module provides access to the ISO
 
97
<p>The <code class="inline"><span class="w">Locale::Country</span></code>
 
98
 module provides access to the ISO
98
99
codes for identifying countries, as defined in ISO 3166-1.
99
100
You can either access the codes via the <a href="#conversion-routines">"conversion routines"</a>
100
101
(described below), or with the two functions which return lists
104
105
<ul>
105
106
<li><a name="*alpha-2*"></a><b><b>alpha-2</b></b>
106
107
<p>Two letter codes, such as 'tv' for Tuvalu.
107
 
This code set is identified with the symbol <code class="inline">LOCALE_CODE_ALPHA_2</code>
 
108
This code set is identified with the symbol <code class="inline"><span class="w">LOCALE_CODE_ALPHA_2</span></code>
108
109
.</p>
109
110
</li>
110
111
<li><a name="*alpha-3*"></a><b><b>alpha-3</b></b>
111
112
<p>Three letter codes, such as 'brb' for Barbados.
112
 
This code set is identified with the symbol <code class="inline">LOCALE_CODE_ALPHA_3</code>
 
113
This code set is identified with the symbol <code class="inline"><span class="w">LOCALE_CODE_ALPHA_3</span></code>
113
114
.</p>
114
115
</li>
115
116
<li><a name="*numeric*"></a><b><b>numeric</b></b>
116
117
<p>Numeric codes, such as 064 for Bhutan.
117
 
This code set is identified with the symbol <code class="inline">LOCALE_CODE_NUMERIC</code>
 
118
This code set is identified with the symbol <code class="inline"><span class="w">LOCALE_CODE_NUMERIC</span></code>
118
119
.</p>
119
120
</li>
120
121
</ul>
133
134
is "us", so country2code('United States') returns 'us'.
134
135
Now the following will also return 'us':</p>
135
136
<pre class="verbatim">    country2code('United States of America') 
136
 
    country2code('USA') </pre><a name="CONVERSION-ROUTINES"></a><h1>CONVERSION ROUTINES</h1>
 
137
    country2code('USA')</pre><a name="CONVERSION-ROUTINES"></a><h1>CONVERSION ROUTINES</h1>
137
138
<p>There are three conversion routines: <code class="inline"><span class="i">code2country</span><span class="s">(</span><span class="s">)</span></code>
138
139
, <code class="inline"><span class="i">country2code</span><span class="s">(</span><span class="s">)</span></code>
139
140
,
152
153
country code, if such exists.
153
154
If the argument could not be identified as a country name,
154
155
then <code class="inline"><a class="l_k" href="../functions/undef.html">undef</a></code> will be returned:</p>
155
 
<pre class="verbatim">    <span class="i">$code</span> = <span class="i">country2code</span><span class="s">(</span><span class="q">&#39;Norway&#39;</span><span class="cm">,</span> LOCALE_CODE_ALPHA_3<span class="s">)</span><span class="sc">;</span>
 
156
<pre class="verbatim">    <span class="i">$code</span> = <span class="i">country2code</span><span class="s">(</span><span class="q">&#39;Norway&#39;</span><span class="cm">,</span> <span class="w">LOCALE_CODE_ALPHA_3</span><span class="s">)</span><span class="sc">;</span>
156
157
    <span class="c"># $code will now be &#39;nor&#39;</span></pre>
157
158
<p>The case of the country name is not important.
158
159
See the section <a href="#KNOWN-BUGS-AND-LIMITATIONS">"KNOWN BUGS AND LIMITATIONS"</a> below.</p>
161
162
<p>This function takes a country code from one code set,
162
163
and returns the corresponding code from another code set.</p>
163
164
<pre class="verbatim">    <span class="i">$alpha2</span> = <span class="i">country_code2code</span><span class="s">(</span><span class="q">&#39;fin&#39;</span><span class="cm">,</span>
164
 
                 LOCALE_CODE_ALPHA_3<span class="cm">,</span> LOCALE_CODE_ALPHA_2<span class="s">)</span><span class="sc">;</span>
 
165
                 <span class="w">LOCALE_CODE_ALPHA_3</span><span class="cm">,</span> <span class="w">LOCALE_CODE_ALPHA_2</span><span class="s">)</span><span class="sc">;</span>
165
166
    <span class="c"># $alpha2 will now be &#39;fi&#39;</span></pre>
166
167
<p>If the code passed is not a valid country code in
167
168
the first code set, or if there isn't a code for the
173
174
<p>There are two function which can be used to obtain a list of all codes,
174
175
or all country names:</p>
175
176
<ul>
176
 
<li><a name="'all_country_codes(-%5b-CODESET-%5d-)'"></a><b><code class="inline"><span class="i">all_country_codes</span><span class="s">(</span> <span class="s">[</span> CODESET <span class="s">]</span> <span class="s">)</span></code>
 
177
<li><a name="'all_country_codes(-%5b-CODESET-%5d-)'"></a><b><code class="inline"><span class="i">all_country_codes</span><span class="s">(</span> <span class="s">[</span> <span class="w">CODESET</span> <span class="s">]</span> <span class="s">)</span></code>
177
178
</b>
178
179
<p>Returns a list of all two-letter country codes.
179
180
The codes are guaranteed to be all lower-case,
180
181
and not in any particular order.</p>
181
182
</li>
182
 
<li><a name="'all_country_names(-%5b-CODESET-%5d-)'"></a><b><code class="inline"><span class="i">all_country_names</span><span class="s">(</span> <span class="s">[</span> CODESET <span class="s">]</span> <span class="s">)</span></code>
 
183
<li><a name="'all_country_names(-%5b-CODESET-%5d-)'"></a><b><code class="inline"><span class="i">all_country_names</span><span class="s">(</span> <span class="s">[</span> <span class="w">CODESET</span> <span class="s">]</span> <span class="s">)</span></code>
183
184
</b>
184
185
<p>Returns a list of all country names for which there is a corresponding
185
186
country code in the specified code set.
198
199
package name.</p>
199
200
<a name="alias_code"></a><h2>alias_code</h2>
200
201
<p>Define a new code as an alias for an existing code:</p>
201
 
<pre class="verbatim">    <span class="i">Locale::Country::alias_code</span><span class="s">(</span> ALIAS <span class="cm">=&gt;</span> CODE <span class="s">[</span><span class="cm">,</span> CODESET <span class="s">]</span> <span class="s">)</span></pre>
 
202
<pre class="verbatim">    <span class="i">Locale::Country::alias_code</span><span class="s">(</span> <span class="w">ALIAS</span> <span class="cm">=&gt;</span> <span class="w">CODE</span> <span class="s">[</span><span class="cm">,</span> <span class="w">CODESET</span> <span class="s">]</span> <span class="s">)</span></pre>
202
203
<p>This feature was added as a mechanism for handling
203
204
a "uk" code. The ISO standard says that the two-letter code for
204
205
"United Kingdom" is "gb", whereas domain names are all .uk.</p>
228
229
 function.
229
230
The user is prompted for a country code, and then told the corresponding
230
231
country name:</p>
231
 
<pre class="verbatim">    <span class="i">$|</span> = <span class="n">1</span><span class="sc">;</span>   <span class="c"># turn off buffering</span>
232
 
    
233
 
    <a class="l_k" href="../functions/print.html">print</a> <span class="q">&quot;Enter country code: &quot;</span><span class="sc">;</span>
 
232
<pre class="verbatim">    <span class="i">$|</span> = <span class="n">1</span><span class="sc">;</span>   <span class="c"># turn off buffering</span></pre>
 
233
<pre class="verbatim">    <a class="l_k" href="../functions/print.html">print</a> <span class="q">&quot;Enter country code: &quot;</span><span class="sc">;</span>
234
234
    <a class="l_k" href="../functions/chop.html">chop</a><span class="s">(</span><span class="i">$code</span> = <span class="q">&lt;STDIN&gt;</span><span class="s">)</span><span class="sc">;</span>
235
 
    <span class="i">$country</span> = <span class="i">code2country</span><span class="s">(</span><span class="i">$code</span><span class="cm">,</span> LOCALE_CODE_ALPHA_2<span class="s">)</span><span class="sc">;</span>
 
235
    <span class="i">$country</span> = <span class="i">code2country</span><span class="s">(</span><span class="i">$code</span><span class="cm">,</span> <span class="w">LOCALE_CODE_ALPHA_2</span><span class="s">)</span><span class="sc">;</span>
236
236
    if <span class="s">(</span><a class="l_k" href="../functions/defined.html">defined</a> <span class="i">$country</span><span class="s">)</span>
237
237
    <span class="s">{</span>
238
238
        <a class="l_k" href="../functions/print.html">print</a> <span class="q">&quot;$code = $country\n&quot;</span><span class="sc">;</span>
323
323
          <!--<select name="r"><option value="1" selected>Go to top result<option value="0">Show results list</select>-->
324
324
        </form>
325
325
      </p>
 
326
      <script language="JavaScript" type="text/javascript" src="/perl-version.js"></script>
326
327
      <h2>Labels:</h2>
327
328
      <p>
328
329
        <a href="#" onClick="addLabel('Locale::Country','Locale/Country.html')">Add this page</a>