4 Locale::Script - ISO codes for script identification (ISO 15924)
11 $script = code2script('ph'); # 'Phoenician'
12 $code = script2code('Tibetan'); # 'bo'
13 $code3 = script2code('Tibetan',
14 LOCALE_CODE_ALPHA_3); # 'bod'
15 $codeN = script2code('Tibetan',
16 LOCALE_CODE_ALPHA_NUMERIC); # 330
18 @codes = all_script_codes();
19 @scripts = all_script_names();
24 The C<Locale::Script> module provides access to the ISO
25 codes for identifying scripts, as defined in ISO 15924.
26 For example, Egyptian hieroglyphs are denoted by the two-letter
27 code 'eg', the three-letter code 'egy', and the numeric code 050.
29 You can either access the codes via the conversion routines
30 (described below), or with the two functions which return lists
31 of all script codes or all script names.
33 There are three different code sets you can use for identifying
40 Two letter codes, such as 'bo' for Tibetan.
41 This code set is identified with the symbol C<LOCALE_CODE_ALPHA_2>.
45 Three letter codes, such as 'ell' for Greek.
46 This code set is identified with the symbol C<LOCALE_CODE_ALPHA_3>.
50 Numeric codes, such as 410 for Hiragana.
51 This code set is identified with the symbol C<LOCALE_CODE_NUMERIC>.
55 All of the routines take an optional additional argument
56 which specifies the code set to use.
57 If not specified, it defaults to the two-letter codes.
58 This is partly for backwards compatibility (previous versions
59 of Locale modules only supported the alpha-2 codes), and
60 partly because they are the most widely used codes.
62 The alpha-2 and alpha-3 codes are not case-dependent,
63 so you can use 'BO', 'Bo', 'bO' or 'bo' for Tibetan.
64 When a code is returned by one of the functions in
65 this module, it will always be lower-case.
69 The standard defines various special codes.
75 The standard reserves codes in the ranges B<qa> - B<qt>,
76 B<qaa> - B<qat>, and B<900> - B<919>, for private use.
80 B<zx>, B<zxx>, and B<997>, are the codes for unwritten languages.
84 B<zy>, B<zyy>, and B<998>, are the codes for an undetermined script.
88 B<zz>, B<zzz>, and B<999>, are the codes for an uncoded script.
92 The private codes are not recognised by Locale::Script,
96 =head1 CONVERSION ROUTINES
98 There are three conversion routines: C<code2script()>, C<script2code()>,
99 and C<script_code2code()>.
103 =item code2script( CODE, [ CODESET ] )
105 This function takes a script code and returns a string
106 which contains the name of the script identified.
107 If the code is not a valid script code, as defined by ISO 15924,
108 then C<undef> will be returned:
110 $script = code2script('cy'); # Cyrillic
112 =item script2code( STRING, [ CODESET ] )
114 This function takes a script name and returns the corresponding
115 script code, if such exists.
116 If the argument could not be identified as a script name,
117 then C<undef> will be returned:
119 $code = script2code('Gothic', LOCALE_CODE_ALPHA_3);
120 # $code will now be 'gth'
122 The case of the script name is not important.
123 See the section L<KNOWN BUGS AND LIMITATIONS> below.
125 =item script_code2code( CODE, CODESET, CODESET )
127 This function takes a script code from one code set,
128 and returns the corresponding code from another code set.
130 $alpha2 = script_code2code('jwi',
131 LOCALE_CODE_ALPHA_3 => LOCALE_CODE_ALPHA_2);
132 # $alpha2 will now be 'jw' (Javanese)
134 If the code passed is not a valid script code in
135 the first code set, or if there isn't a code for the
136 corresponding script in the second code set,
137 then C<undef> will be returned.
142 =head1 QUERY ROUTINES
144 There are two function which can be used to obtain a list of all codes,
149 =item C<all_script_codes ( [ CODESET ] )>
151 Returns a list of all two-letter script codes.
152 The codes are guaranteed to be all lower-case,
153 and not in any particular order.
155 =item C<all_script_names ( [ CODESET ] )>
157 Returns a list of all script names for which there is a corresponding
158 script code in the specified code set.
159 The names are capitalised, and not returned in any particular order.
166 The following example illustrates use of the C<code2script()> function.
167 The user is prompted for a script code, and then told the corresponding
170 $| = 1; # turn off buffering
172 print "Enter script code: ";
173 chop($code = <STDIN>);
174 $script = code2script($code, LOCALE_CODE_ALPHA_2);
177 print "$code = $script\n";
181 print "'$code' is not a valid script code!\n";
185 =head1 KNOWN BUGS AND LIMITATIONS
191 When using C<script2code()>, the script name must currently appear
192 exactly as it does in the source of the module. For example,
194 script2code('Egyptian hieroglyphs')
196 will return B<eg>, as expected. But the following will all return C<undef>:
198 script2code('hieroglyphs')
199 script2code('Egyptian Hieroglypics')
201 If there's need for it, a future version could have variants
206 In the current implementation, all data is read in when the
207 module is loaded, and then held in memory.
208 A lazy implementation would be more memory friendly.
216 =item Locale::Language
218 ISO two letter codes for identification of language (ISO 639).
220 =item Locale::Currency
222 ISO three letter codes for identification of currencies
223 and funds (ISO 4217).
225 =item Locale::Country
227 ISO three letter codes for identification of countries (ISO 3166)
231 The ISO standard which defines these codes.
233 =item http://www.evertype.com/standards/iso15924/
235 Home page for ISO 15924.
243 Neil Bowers E<lt>neil@bowers.comE<gt>
247 Copyright (c) 2002 Neil Bowers.
249 This module is free software; you can redistribute it and/or
250 modify it under the same terms as Perl itself.