=head1 NAME
perllocale - Perl locale handling (internationalization and localization)
=head1 DESCRIPTION
Perl supports language-specific notions of data such as "is this
a letter", "what is the uppercase equivalent of this letter", and
"which of these letters comes first". These are important issues,
especially for languages other than English--but also for English: it
would be naEve to imagine that C defines all the "letters"
needed to write in English. Perl is also aware that some character other
than '.' may be preferred as a decimal point, and that output date
representations may be language-specific. The process of making an
application take account of its users' preferences in such matters is
called B (often abbreviated as B); telling
such an application about a particular set of preferences is known as
B (B).
Perl can understand language-specific data via the standardized (ISO C,
XPG4, POSIX 1.c) method called "the locale system". The locale system is
controlled per application using one pragma, one function call, and
several environment variables.
B: This feature is new in Perl 5.004, and does not apply unless an
application specifically requests it--see L.
The one exception is that write() now B uses the current locale
- see L<"NOTES">.
=head1 PREPARING TO USE LOCALES
If Perl applications are to understand and present your data
correctly according a locale of your choice, B of the following
must be true:
=over 4
=item *
B. If it does,
you should find that the setlocale() function is a documented part of
its C library.
=item *
B. You, or
your system administrator, must make sure that this is the case. The
available locales, the location in which they are kept, and the manner
in which they are installed all vary from system to system. Some systems
provide only a few, hard-wired locales and do not allow more to be
added. Others allow you to add "canned" locales provided by the system
supplier. Still others allow you or the system administrator to define
and add arbitrary locales. (You may have to ask your supplier to
provide canned locales that are not delivered with your operating
system.) Read your system documentation for further illumination.
=item *
B. If it does,
C will say that the value for C is
C.
=back
If you want a Perl application to process and present your data
according to a particular locale, the application code should include
the S> pragma (see L) where
appropriate, and B of the following must be true:
=over 4
=item *
B)
must be correctly set up> at the time the application is started, either
by yourself or by whoever set up your system account.
=item *
B using the method described in
L.
=back
=head1 USING LOCALES
=head2 The use locale pragma
By default, Perl ignores the current locale. The S>
pragma tells Perl to use the current locale for some operations:
=over 4
=item *
B (C, C, C, C, and C) and
the POSIX string collation functions strcoll() and strxfrm() use
C. sort() is also affected if used without an
explicit comparison function, because it uses C by default.
B C and C are unaffected by locale: they always
perform a char-by-char comparison of their scalar operands. What's
more, if C finds that its operands are equal according to the
collation sequence specified by the current locale, it goes on to
perform a char-by-char comparison, and only returns I<0> (equal) if the
operands are char-for-char identical. If you really want to know whether
two strings--which C and C may consider different--are equal
as far as collation in the locale is concerned, see the discussion in
L.
=item *
B (uc(), lc(),
ucfirst(), and lcfirst()) use C
=item *
B (printf(), sprintf() and write()) use
C
=item *
B (strftime()) uses C.
=back
C, C, and so on, are discussed further in
L.
The default behavior is restored with the S> pragma, or
upon reaching the end of block enclosing C