home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _806bf059ae36f627848c75da9e7a748f < prev    next >
Encoding:
Text File  |  2000-03-23  |  8.3 KB  |  224 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Locale::Country - ISO two letter codes for country identification</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> Locale::Country - ISO two letter codes for country identification</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#conversion routines">CONVERSION ROUTINES</A></LI>
  26.     <LI><A HREF="#query routines">QUERY ROUTINES</A></LI>
  27.     <LI><A HREF="#code aliasing">CODE ALIASING</A></LI>
  28.     <LI><A HREF="#examples">EXAMPLES</A></LI>
  29.     <LI><A HREF="#domain names">DOMAIN NAMES</A></LI>
  30.     <LI><A HREF="#known bugs and limitations">KNOWN BUGS AND LIMITATIONS</A></LI>
  31.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  32.     <LI><A HREF="#author">AUTHOR</A></LI>
  33.     <LI><A HREF="#copyright">COPYRIGHT</A></LI>
  34. </UL>
  35. <!-- INDEX END -->
  36.  
  37. <HR>
  38. <P>
  39. <H1><A NAME="name">NAME</A></H1>
  40. <P>Locale::Country - ISO two letter codes for country identification (ISO 3166)</P>
  41. <P>
  42. <HR>
  43. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  44. <UL>
  45. <LI>Linux</LI>
  46. <LI>Solaris</LI>
  47. <LI>Windows</LI>
  48. </UL>
  49. <HR>
  50. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  51. <PRE>
  52.     use Locale::Country;
  53. </PRE>
  54. <PRE>
  55.  
  56.     $country = code2country('jp');               # $country gets 'Japan'
  57.     $code    = country2code('Norway');           # $code gets 'no'</PRE>
  58. <PRE>
  59.  
  60.     @codes   = all_country_codes();
  61.     @names   = all_country_names();</PRE>
  62. <PRE>
  63.  
  64.     Locale::Country::_alias_code('uk' => 'gb');  # allow "uk": United Kingdom</PRE>
  65. <P>
  66. <HR>
  67. <H1><A NAME="description">DESCRIPTION</A></H1>
  68. <P>The <CODE>Locale::Country</CODE> module provides access to the ISO two-letter
  69. codes for identifying countries, as defined in ISO 3166. You can either
  70. access the codes via the <A HREF="#conversion routines">conversion routines</A> (described below),
  71. or with the two functions which return lists of all country codes or
  72. all country names.</P>
  73. <P>
  74. <HR>
  75. <H1><A NAME="conversion routines">CONVERSION ROUTINES</A></H1>
  76. <P>There are two conversion routines: <A HREF="#item_code2country"><CODE>code2country()</CODE></A> and <A HREF="#item_country2code"><CODE>country2code()</CODE></A>.</P>
  77. <DL>
  78. <DT><STRONG><A NAME="item_code2country"><CODE>code2country()</CODE></A></STRONG><BR>
  79. <DD>
  80. This function takes a two letter country code and returns a string
  81. which contains the name of the country identified. If the code is
  82. not a valid country code, as defined by ISO 3166, then <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A>
  83. will be returned:
  84. <PRE>
  85.     $country = code2country('fi');</PRE>
  86. <P></P>
  87. <DT><STRONG><A NAME="item_country2code"><CODE>country2code()</CODE></A></STRONG><BR>
  88. <DD>
  89. This function takes a country name and returns the corresponding
  90. two letter country code, if such exists.
  91. If the argument could not be identified as a country name,
  92. then <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> will be returned:
  93. <PRE>
  94.     $code = country2code('Norway');</PRE>
  95. <P>The case of the country name is not important.
  96. See the section <A HREF="#known bugs and limitations">KNOWN BUGS AND LIMITATIONS</A> below.</P>
  97. <P></P></DL>
  98. <P>
  99. <HR>
  100. <H1><A NAME="query routines">QUERY ROUTINES</A></H1>
  101. <P>There are two function which can be used to obtain a list of all codes,
  102. or all country names:</P>
  103. <DL>
  104. <DT><STRONG><A NAME="item_all_country_codes"><CODE>all_country_codes()</CODE></A></STRONG><BR>
  105. <DD>
  106. Returns a list of all two-letter country codes.
  107. The codes are guaranteed to be all lower-case,
  108. and not in any particular order.
  109. <P></P>
  110. <DT><STRONG><A NAME="item_all_country_names"><CODE>all_country_names()</CODE></A></STRONG><BR>
  111. <DD>
  112. Returns a list of all country names for which there is a corresponding
  113. two-letter country code. The names are capitalised, and not returned
  114. in any particular order.
  115. <P></P></DL>
  116. <P>
  117. <HR>
  118. <H1><A NAME="code aliasing">CODE ALIASING</A></H1>
  119. <P>This module supports a semi-private routine for specifying two letter
  120. code aliases. This feature was added as a mechanism for handling
  121. a ``uk'' code. The ISO standard says that the two-letter code for
  122. ``United Kingdom'' is ``gb'', whereas domain names are all .uk.</P>
  123. <P>By default the module does not understand ``uk'', since it is implementing
  124. an ISO standard. If you would like 'uk' to work as the two-letter
  125. code for United Kingdom, use the following:</P>
  126. <PRE>
  127.     use Locale::Country;
  128. </PRE>
  129. <PRE>
  130.  
  131.     Locale::Country::_alias_code('uk' => 'gb');</PRE>
  132. <P>With this code, both ``uk'' and ``gb'' are valid codes for United Kingdom,
  133. with the reverse lookup returning ``uk'' rather than the usual ``gb''.</P>
  134. <P>
  135. <HR>
  136. <H1><A NAME="examples">EXAMPLES</A></H1>
  137. <P>The following example illustrates use of the <A HREF="#item_code2country"><CODE>code2country()</CODE></A> function.
  138. The user is prompted for a country code, and then told the corresponding
  139. country name:</P>
  140. <PRE>
  141.     $| = 1;   # turn off buffering
  142. </PRE>
  143. <PRE>
  144.  
  145.     print "Enter country code: ";
  146.     chop($code = <STDIN>);
  147.     $country = code2country($code);
  148.     if (defined $country)
  149.     {
  150.         print "$code = $country\n";
  151.     }
  152.     else
  153.     {
  154.         print "'$code' is not a valid country code!\n";
  155.     }</PRE>
  156. <P>
  157. <HR>
  158. <H1><A NAME="domain names">DOMAIN NAMES</A></H1>
  159. <P>Most top-level domain names are based on these codes,
  160. but there are certain codes which aren't.
  161. If you are using this module to identify country from hostname,
  162. your best bet is to preprocess the country code.</P>
  163. <P>For example, <STRONG>edu</STRONG>, <STRONG>com</STRONG>, <STRONG>gov</STRONG> and friends would map to <STRONG>us</STRONG>;
  164. <STRONG>uk</STRONG> would map to <STRONG>gb</STRONG>. Any others?</P>
  165. <P>
  166. <HR>
  167. <H1><A NAME="known bugs and limitations">KNOWN BUGS AND LIMITATIONS</A></H1>
  168. <UL>
  169. <LI>
  170. When using <A HREF="#item_country2code"><CODE>country2code()</CODE></A>, the country name must currently appear
  171. exactly as it does in the source of the module. For example,
  172. <PRE>
  173.     country2code('United States')</PRE>
  174. <P>will return <STRONG>us</STRONG>, as expected. But the following will all return <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A>:</P>
  175. <PRE>
  176.     country2code('United States of America')
  177.     country2code('Great Britain')
  178.     country2code('U.S.A.')</PRE>
  179. <P>If there's need for it, a future version could have variants
  180. for country names.</P>
  181. <P></P>
  182. <LI>
  183. In the current implementation, all data is read in when the
  184. module is loaded, and then held in memory.
  185. A lazy implementation would be more memory friendly.
  186. <P></P></UL>
  187. <P>
  188. <HR>
  189. <H1><A NAME="see also">SEE ALSO</A></H1>
  190. <DL>
  191. <DT><STRONG><A NAME="item_Locale%3A%3ALanguage">Locale::Language</A></STRONG><BR>
  192. <DD>
  193. ISO two letter codes for identification of language (ISO 639).
  194. <P></P>
  195. <DT><STRONG><A NAME="item_ISO_3166">ISO 3166</A></STRONG><BR>
  196. <DD>
  197. The ISO standard which defines these codes.
  198. <P></P>
  199. <DT><STRONG><A NAME="item_ftp%3A%2F%2Finfo%2Eripe%2Enet%2Fiso3166%2Dcountryc"><A HREF="ftp://info.ripe.net/iso3166-countrycodes">ftp://info.ripe.net/iso3166-countrycodes</A></A></STRONG><BR>
  200. <DD>
  201. Online file with the two-letter codes, three-letter codes,
  202. and country code numbers.
  203. Maintained by the RIPE Network Coordination Centre.
  204. <P></P></DL>
  205. <P>
  206. <HR>
  207. <H1><A NAME="author">AUTHOR</A></H1>
  208. <P>Neil Bowers <<A HREF="mailto:neilb@cre.canon.co.uk">neilb@cre.canon.co.uk</A>></P>
  209. <P>
  210. <HR>
  211. <H1><A NAME="copyright">COPYRIGHT</A></H1>
  212. <P>Copyright (c) 1997,1998 Canon Research Centre Europe (CRE).</P>
  213. <P>This module is free software; you can redistribute it and/or
  214. modify it under the same terms as Perl itself.</P>
  215. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  216. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  217. <STRONG><P CLASS=block> Locale::Country - ISO two letter codes for country identification</P></STRONG>
  218. </TD></TR>
  219. </TABLE>
  220.  
  221. </BODY>
  222.  
  223. </HTML>
  224.