X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperllocale.pod;h=8f7ce041386ab199b10ce32bca3a3afadc58112f;hb=8269e00da02a2e0f107fbb8b4a78f0c4058f3587;hp=f680c73109a560648fcd286e99609676a2abb40e;hpb=cea6626fc5e04af2c1d079dd4d3784eb2c21174b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perllocale.pod b/pod/perllocale.pod index f680c73..8f7ce04 100644 --- a/pod/perllocale.pod +++ b/pod/perllocale.pod @@ -99,11 +99,11 @@ 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 byte-by-byte comparison of their scalar operands. What's +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 byte-by-byte comparison, and only returns I<0> (equal) if the -operands are bit-for-bit identical. If you really want to know whether +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. @@ -293,7 +293,7 @@ programs you run see the changes. See L for the full list of relevant environment variables and L for their effects in Perl. Effects in other programs are easily deducible. For example, the variable LC_COLLATE may well affect -your B program (or whatever the program that arranges `records' +your B program (or whatever the program that arranges "records" alphabetically in your system is called). You can test out changing these variables temporarily, and if the @@ -310,6 +310,10 @@ locale "En_US"--and in Cshish shells (B, B) setenv LC_ALL en_US.ISO8859-1 +or if you have the "env" application you can do in any shell + + env LC_ALL=en_US.ISO8859-1 perl ... + If you do not know what shell you have, consult your local helpdesk or the equivalent. @@ -427,6 +431,31 @@ parameters as integers correctly formatted in the current locale: } print "\n"; +=head2 I18N::Langinfo + +Another interface for querying locale-dependent information is the +I18N::Langinfo::langinfo() function, available at least in UNIX-like +systems and VMS. + +The following example will import the langinfo() function itself and +three constants to be used as arguments to langinfo(): a constant for +the abbreviated first day of the week (the numbering starts from +Sunday = 1) and two more constants for the affirmative and negative +answers for a yes/no question in the current locale. + + use I18N::Langinfo qw(langinfo ABDAY_1 YESSTR NOSTR); + + my ($abday_1, $yesstr, $nostr) = map { langinfo } qw(ABDAY_1 YESSTR NOSTR); + + print "$abday_1? [$yesstr/$nostr] "; + +In other words, in the "C" (or English) locale the above will probably +print something like: + + Sun? [yes/no] + +See L for more information. + =head1 LOCALE CATEGORIES The following subsections describe basic locale categories. Beyond these, @@ -468,7 +497,7 @@ first example is useful for natural text. As noted in L, C compares according to the current collation locale when C is in effect, but falls back to a -byte-by-byte comparison for strings that the locale says are equal. You +char-by-char comparison for strings that the locale says are equal. You can use POSIX::strcoll() if you don't want this fall-back: use POSIX qw(strcoll); @@ -493,9 +522,9 @@ efficiency by using POSIX::strxfrm() in conjunction with C: if $xfrm_string eq strxfrm("mixed-case string"); strxfrm() takes a string and maps it into a transformed string for use -in byte-by-byte comparisons against other transformed strings during +in char-by-char comparisons against other transformed strings during collation. "Under the hood", locale-affected Perl comparison operators -call strxfrm() for both operands, then do a byte-by-byte +call strxfrm() for both operands, then do a char-by-char comparison of the transformed strings. By calling strxfrm() explicitly and using a non locale-affected comparison, the example attempts to save a couple of transformations. But in fact, it doesn't save anything: Perl @@ -574,6 +603,8 @@ string formats: print "DECIMAL POINT IS COMMA\n" if $n == (strtod("2,5"))[0]; # Locale-dependent conversion +See also L and C. + =head2 Category LC_MONETARY: Formatting of monetary amounts The C standard defines the C category, but no function @@ -587,6 +618,8 @@ find that the information, voluminous and complex though it may be, still does not quite meet your requirements: currency formatting is a hard nut to crack. +See also L and C. + =head2 LC_TIME Output produced by POSIX::strftime(), which builds a formatted @@ -606,6 +639,9 @@ Note: C isn't needed in this example: as a function that exists only to generate locale-dependent results, strftime() always obeys the current C locale. +See also L and C..C, C..C, +C..C, and C..C. + =head2 Other categories The remaining locale category, C (possibly supplemented @@ -700,8 +736,8 @@ Scalar true/false result never tainted. Subpatterns, either delivered as a list-context result or as $1 etc. are tainted if C is in effect, and the subpattern regular expression contains C<\w> (to match an alphanumeric character), C<\W> -(non-alphanumeric character), C<\s> (white-space character), or C<\S> -(non white-space character). The matched-pattern variable, $&, $` +(non-alphanumeric character), C<\s> (whitespace character), or C<\S> +(non whitespace character). The matched-pattern variable, $&, $` (pre-match), $' (post-match), and $+ (last match) are also tainted if C is in effect and the regular expression contains C<\w>, C<\W>, C<\s>, or C<\S>. @@ -925,7 +961,7 @@ structure. =head2 Freely available locale definitions There is a large collection of locale definitions at -C. You should be aware that it is +ftp://dkuug.dk/i18n/WG15-collection . You should be aware that it is unsupported, and is not claimed to be fit for any purpose. If your system allows installation of arbitrary locales, you may find the definitions useful as they are, or as a basis for the development of @@ -949,6 +985,15 @@ nations, when we all know that the world can equally well be divided into bankers, bikers, gamers, and so on. But, for now, it's the only standard we've got. This may be construed as a bug. +=head1 Unicode and UTF-8 + +The support of Unicode is new starting from Perl version 5.6, and +more fully implemented in the version 5.8. See L and +L for more details. + +Usually locale settings and Unicode do not affect each other, but +there are exceptions, see L for examples. + =head1 BUGS =head2 Broken systems @@ -964,12 +1009,13 @@ operating system upgrade. =head1 SEE ALSO -L, L, L, -L, L, L, -L, L, L, -L, L, L, -L, L, L, -L. +L, L, L, L, +L, L, +L, L, L, +L, L, L, +L, L, L, +L, L, L, +L, L. =head1 HISTORY