1Locale::Script(3pm)    Perl Programmers Reference Guide    Locale::Script(3pm)
2
3
4

NAME

6       Locale::Script - ISO codes for script identification (ISO 15924)
7

SYNOPSIS

9           use Locale::Script;
10           use Locale::Constants;
11
12           $script  = code2script('ph');                       # 'Phoenician'
13           $code    = script2code('Tibetan');                  # 'bo'
14           $code3   = script2code('Tibetan',
15                                  LOCALE_CODE_ALPHA_3);        # 'bod'
16           $codeN   = script2code('Tibetan',
17                                  LOCALE_CODE_ALPHA_NUMERIC);  # 330
18
19           @codes   = all_script_codes();
20           @scripts = all_script_names();
21

DESCRIPTION

23       The "Locale::Script" module provides access to the ISO codes for
24       identifying scripts, as defined in ISO 15924.  For example, Egyptian
25       hieroglyphs are denoted by the two-letter code 'eg', the three-letter
26       code 'egy', and the numeric code 050.
27
28       You can either access the codes via the conversion routines (described
29       below), or with the two functions which return lists of all script
30       codes or all script names.
31
32       There are three different code sets you can use for identifying
33       scripts:
34
35       alpha-2
36           Two letter codes, such as 'bo' for Tibetan.  This code set is
37           identified with the symbol "LOCALE_CODE_ALPHA_2".
38
39       alpha-3
40           Three letter codes, such as 'ell' for Greek.  This code set is
41           identified with the symbol "LOCALE_CODE_ALPHA_3".
42
43       numeric
44           Numeric codes, such as 410 for Hiragana.  This code set is
45           identified with the symbol "LOCALE_CODE_NUMERIC".
46
47       All of the routines take an optional additional argument which
48       specifies the code set to use.  If not specified, it defaults to the
49       two-letter codes.  This is partly for backwards compatibility (previous
50       versions of Locale modules only supported the alpha-2 codes), and
51       partly because they are the most widely used codes.
52
53       The alpha-2 and alpha-3 codes are not case-dependent, so you can use
54       'BO', 'Bo', 'bO' or 'bo' for Tibetan.  When a code is returned by one
55       of the functions in this module, it will always be lower-case.
56
57   SPECIAL CODES
58       The standard defines various special codes.
59
60       ·   The standard reserves codes in the ranges qa - qt, qaa - qat, and
61           900 - 919, for private use.
62
63       ·   zx, zxx, and 997, are the codes for unwritten languages.
64
65       ·   zy, zyy, and 998, are the codes for an undetermined script.
66
67       ·   zz, zzz, and 999, are the codes for an uncoded script.
68
69       The private codes are not recognised by Locale::Script, but the others
70       are.
71

CONVERSION ROUTINES

73       There are three conversion routines: "code2script()", "script2code()",
74       and "script_code2code()".
75
76       code2script( CODE, [ CODESET ] )
77           This function takes a script code and returns a string which
78           contains the name of the script identified.  If the code is not a
79           valid script code, as defined by ISO 15924, then "undef" will be
80           returned:
81
82               $script = code2script('cy');   # Cyrillic
83
84       script2code( STRING, [ CODESET ] )
85           This function takes a script name and returns the corresponding
86           script code, if such exists.  If the argument could not be
87           identified as a script name, then "undef" will be returned:
88
89               $code = script2code('Gothic', LOCALE_CODE_ALPHA_3);
90               # $code will now be 'gth'
91
92           The case of the script name is not important.  See the section
93           "KNOWN BUGS AND LIMITATIONS" below.
94
95       script_code2code( CODE, CODESET, CODESET )
96           This function takes a script code from one code set, and returns
97           the corresponding code from another code set.
98
99               $alpha2 = script_code2code('jwi',
100                            LOCALE_CODE_ALPHA_3 => LOCALE_CODE_ALPHA_2);
101               # $alpha2 will now be 'jw' (Javanese)
102
103           If the code passed is not a valid script code in the first code
104           set, or if there isn't a code for the corresponding script in the
105           second code set, then "undef" will be returned.
106

QUERY ROUTINES

108       There are two function which can be used to obtain a list of all codes,
109       or all script names:
110
111       "all_script_codes ( [ CODESET ] )"
112           Returns a list of all two-letter script codes.  The codes are
113           guaranteed to be all lower-case, and not in any particular order.
114
115       "all_script_names ( [ CODESET ] )"
116           Returns a list of all script names for which there is a
117           corresponding script code in the specified code set.  The names are
118           capitalised, and not returned in any particular order.
119

EXAMPLES

121       The following example illustrates use of the "code2script()" function.
122       The user is prompted for a script code, and then told the corresponding
123       script name:
124
125           $| = 1;   # turn off buffering
126
127           print "Enter script code: ";
128           chop($code = <STDIN>);
129           $script = code2script($code, LOCALE_CODE_ALPHA_2);
130           if (defined $script)
131           {
132               print "$code = $script\n";
133           }
134           else
135           {
136               print "'$code' is not a valid script code!\n";
137           }
138

KNOWN BUGS AND LIMITATIONS

140       ·   When using "script2code()", the script name must currently appear
141           exactly as it does in the source of the module. For example,
142
143               script2code('Egyptian hieroglyphs')
144
145           will return eg, as expected. But the following will all return
146           "undef":
147
148               script2code('hieroglyphs')
149               script2code('Egyptian Hieroglypics')
150
151           If there's need for it, a future version could have variants for
152           script names.
153
154       ·   In the current implementation, all data is read in when the module
155           is loaded, and then held in memory.  A lazy implementation would be
156           more memory friendly.
157

SEE ALSO

159       Locale::Language
160           ISO two letter codes for identification of language (ISO 639).
161
162       Locale::Currency
163           ISO three letter codes for identification of currencies and funds
164           (ISO 4217).
165
166       Locale::Country
167           ISO three letter codes for identification of countries (ISO 3166)
168
169       ISO 15924
170           The ISO standard which defines these codes.
171
172       http://www.evertype.com/standards/iso15924/
173           Home page for ISO 15924.
174

AUTHOR

176       Neil Bowers <neil@bowers.com>
177
179       Copyright (c) 2002-2004 Neil Bowers.
180
181       This module is free software; you can redistribute it and/or modify it
182       under the same terms as Perl itself.
183
184
185
186perl v5.12.4                      2011-06-07               Locale::Script(3pm)
Impressum