1N/A
1N/A=head1 NAME
1N/A
1N/ALocale::Script - ISO codes for script identification (ISO 15924)
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/A use Locale::Script;
1N/A use Locale::Constants;
1N/A
1N/A $script = code2script('ph'); # 'Phoenician'
1N/A $code = script2code('Tibetan'); # 'bo'
1N/A $code3 = script2code('Tibetan',
1N/A LOCALE_CODE_ALPHA_3); # 'bod'
1N/A $codeN = script2code('Tibetan',
1N/A LOCALE_CODE_ALPHA_NUMERIC); # 330
1N/A
1N/A @codes = all_script_codes();
1N/A @scripts = all_script_names();
1N/A
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/AThe C<Locale::Script> module provides access to the ISO
1N/Acodes for identifying scripts, as defined in ISO 15924.
1N/AFor example, Egyptian hieroglyphs are denoted by the two-letter
1N/Acode 'eg', the three-letter code 'egy', and the numeric code 050.
1N/A
1N/AYou can either access the codes via the conversion routines
1N/A(described below), or with the two functions which return lists
1N/Aof all script codes or all script names.
1N/A
1N/AThere are three different code sets you can use for identifying
1N/Ascripts:
1N/A
1N/A=over 4
1N/A
1N/A=item B<alpha-2>
1N/A
1N/ATwo letter codes, such as 'bo' for Tibetan.
1N/AThis code set is identified with the symbol C<LOCALE_CODE_ALPHA_2>.
1N/A
1N/A=item B<alpha-3>
1N/A
1N/AThree letter codes, such as 'ell' for Greek.
1N/AThis code set is identified with the symbol C<LOCALE_CODE_ALPHA_3>.
1N/A
1N/A=item B<numeric>
1N/A
1N/ANumeric codes, such as 410 for Hiragana.
1N/AThis code set is identified with the symbol C<LOCALE_CODE_NUMERIC>.
1N/A
1N/A=back
1N/A
1N/AAll of the routines take an optional additional argument
1N/Awhich specifies the code set to use.
1N/AIf not specified, it defaults to the two-letter codes.
1N/AThis is partly for backwards compatibility (previous versions
1N/Aof Locale modules only supported the alpha-2 codes), and
1N/Apartly because they are the most widely used codes.
1N/A
1N/AThe alpha-2 and alpha-3 codes are not case-dependent,
1N/Aso you can use 'BO', 'Bo', 'bO' or 'bo' for Tibetan.
1N/AWhen a code is returned by one of the functions in
1N/Athis module, it will always be lower-case.
1N/A
1N/A=head2 SPECIAL CODES
1N/A
1N/AThe standard defines various special codes.
1N/A
1N/A=over 4
1N/A
1N/A=item *
1N/A
1N/AThe standard reserves codes in the ranges B<qa> - B<qt>,
1N/AB<qaa> - B<qat>, and B<900> - B<919>, for private use.
1N/A
1N/A=item *
1N/A
1N/AB<zx>, B<zxx>, and B<997>, are the codes for unwritten languages.
1N/A
1N/A=item *
1N/A
1N/AB<zy>, B<zyy>, and B<998>, are the codes for an undetermined script.
1N/A
1N/A=item *
1N/A
1N/AB<zz>, B<zzz>, and B<999>, are the codes for an uncoded script.
1N/A
1N/A=back
1N/A
1N/AThe private codes are not recognised by Locale::Script,
1N/Abut the others are.
1N/A
1N/A
1N/A=head1 CONVERSION ROUTINES
1N/A
1N/AThere are three conversion routines: C<code2script()>, C<script2code()>,
1N/Aand C<script_code2code()>.
1N/A
1N/A=over 4
1N/A
1N/A=item code2script( CODE, [ CODESET ] )
1N/A
1N/AThis function takes a script code and returns a string
1N/Awhich contains the name of the script identified.
1N/AIf the code is not a valid script code, as defined by ISO 15924,
1N/Athen C<undef> will be returned:
1N/A
1N/A $script = code2script('cy'); # Cyrillic
1N/A
1N/A=item script2code( STRING, [ CODESET ] )
1N/A
1N/AThis function takes a script name and returns the corresponding
1N/Ascript code, if such exists.
1N/AIf the argument could not be identified as a script name,
1N/Athen C<undef> will be returned:
1N/A
1N/A $code = script2code('Gothic', LOCALE_CODE_ALPHA_3);
1N/A # $code will now be 'gth'
1N/A
1N/AThe case of the script name is not important.
1N/ASee the section L<KNOWN BUGS AND LIMITATIONS> below.
1N/A
1N/A=item script_code2code( CODE, CODESET, CODESET )
1N/A
1N/AThis function takes a script code from one code set,
1N/Aand returns the corresponding code from another code set.
1N/A
1N/A $alpha2 = script_code2code('jwi',
1N/A LOCALE_CODE_ALPHA_3 => LOCALE_CODE_ALPHA_2);
1N/A # $alpha2 will now be 'jw' (Javanese)
1N/A
1N/AIf the code passed is not a valid script code in
1N/Athe first code set, or if there isn't a code for the
1N/Acorresponding script in the second code set,
1N/Athen C<undef> will be returned.
1N/A
1N/A=back
1N/A
1N/A
1N/A=head1 QUERY ROUTINES
1N/A
1N/AThere are two function which can be used to obtain a list of all codes,
1N/Aor all script names:
1N/A
1N/A=over 4
1N/A
1N/A=item C<all_script_codes ( [ CODESET ] )>
1N/A
1N/AReturns a list of all two-letter script codes.
1N/AThe codes are guaranteed to be all lower-case,
1N/Aand not in any particular order.
1N/A
1N/A=item C<all_script_names ( [ CODESET ] )>
1N/A
1N/AReturns a list of all script names for which there is a corresponding
1N/Ascript code in the specified code set.
1N/AThe names are capitalised, and not returned in any particular order.
1N/A
1N/A=back
1N/A
1N/A
1N/A=head1 EXAMPLES
1N/A
1N/AThe following example illustrates use of the C<code2script()> function.
1N/AThe user is prompted for a script code, and then told the corresponding
1N/Ascript name:
1N/A
1N/A $| = 1; # turn off buffering
1N/A
1N/A print "Enter script code: ";
1N/A chop($code = <STDIN>);
1N/A $script = code2script($code, LOCALE_CODE_ALPHA_2);
1N/A if (defined $script)
1N/A {
1N/A print "$code = $script\n";
1N/A }
1N/A else
1N/A {
1N/A print "'$code' is not a valid script code!\n";
1N/A }
1N/A
1N/A
1N/A=head1 KNOWN BUGS AND LIMITATIONS
1N/A
1N/A=over 4
1N/A
1N/A=item *
1N/A
1N/AWhen using C<script2code()>, the script name must currently appear
1N/Aexactly as it does in the source of the module. For example,
1N/A
1N/A script2code('Egyptian hieroglyphs')
1N/A
1N/Awill return B<eg>, as expected. But the following will all return C<undef>:
1N/A
1N/A script2code('hieroglyphs')
1N/A script2code('Egyptian Hieroglypics')
1N/A
1N/AIf there's need for it, a future version could have variants
1N/Afor script names.
1N/A
1N/A=item *
1N/A
1N/AIn the current implementation, all data is read in when the
1N/Amodule is loaded, and then held in memory.
1N/AA lazy implementation would be more memory friendly.
1N/A
1N/A=back
1N/A
1N/A=head1 SEE ALSO
1N/A
1N/A=over 4
1N/A
1N/A=item Locale::Language
1N/A
1N/AISO two letter codes for identification of language (ISO 639).
1N/A
1N/A=item Locale::Currency
1N/A
1N/AISO three letter codes for identification of currencies
1N/Aand funds (ISO 4217).
1N/A
1N/A=item Locale::Country
1N/A
1N/AISO three letter codes for identification of countries (ISO 3166)
1N/A
1N/A=item ISO 15924
1N/A
1N/AThe ISO standard which defines these codes.
1N/A
1N/A=item http://www.evertype.com/standards/iso15924/
1N/A
1N/AHome page for ISO 15924.
1N/A
1N/A
1N/A=back
1N/A
1N/A
1N/A=head1 AUTHOR
1N/A
1N/ANeil Bowers E<lt>neil@bowers.comE<gt>
1N/A
1N/A=head1 COPYRIGHT
1N/A
1N/ACopyright (c) 2002 Neil Bowers.
1N/A
1N/AThis module is free software; you can redistribute it and/or
1N/Amodify it under the same terms as Perl itself.
1N/A
1N/A=cut
1N/A