📄 perllocale.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLLOCALE 1".TH PERLLOCALE 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perllocale \- Perl locale handling (internationalization and localization).SH "DESCRIPTION".IX Header "DESCRIPTION"Perl supports language-specific notions of data such as \*(L"is thisa letter\*(R", \*(L"what is the uppercase equivalent of this letter\*(R", and\&\*(L"which of these letters comes first\*(R". These are important issues,especially for languages other than English\*(--but also for English: itwould be nai\*:ve to imagine that \f(CW\*(C`A\-Za\-z\*(C'\fR defines all the \*(L"letters\*(R"needed to write in English. Perl is also aware that some character otherthan '.' may be preferred as a decimal point, and that output daterepresentations may be language-specific. The process of making anapplication take account of its users' preferences in such matters iscalled \fBinternationalization\fR (often abbreviated as \fBi18n\fR); tellingsuch an application about a particular set of preferences is known as\&\fBlocalization\fR (\fBl10n\fR)..PPPerl can understand language-specific data via the standardized (\s-1ISO\s0 C,\&\s-1XPG4\s0, \s-1POSIX\s0 1.c) method called \*(L"the locale system\*(R". The locale system iscontrolled per application using one pragma, one function call, andseveral environment variables..PP\&\fB\s-1NOTE\s0\fR: This feature is new in Perl 5.004, and does not apply unless anapplication specifically requests it\*(--see \*(L"Backward compatibility\*(R".The one exception is that \fIwrite()\fR now \fBalways\fR uses the current locale\&\- see \*(L"\s-1NOTES\s0\*(R"..SH "PREPARING TO USE LOCALES".IX Header "PREPARING TO USE LOCALES"If Perl applications are to understand and present your datacorrectly according a locale of your choice, \fBall\fR of the followingmust be true:.IP "\(bu" 4\&\fBYour operating system must support the locale system\fR. If it does,you should find that the \fIsetlocale()\fR function is a documented part ofits C library..IP "\(bu" 4\&\fBDefinitions for locales that you use must be installed\fR. You, oryour system administrator, must make sure that this is the case. Theavailable locales, the location in which they are kept, and the mannerin which they are installed all vary from system to system. Some systemsprovide only a few, hard-wired locales and do not allow more to beadded. Others allow you to add \*(L"canned\*(R" locales provided by the systemsupplier. Still others allow you or the system administrator to defineand add arbitrary locales. (You may have to ask your supplier toprovide canned locales that are not delivered with your operatingsystem.) Read your system documentation for further illumination..IP "\(bu" 4\&\fBPerl must believe that the locale system is supported\fR. If it does,\&\f(CW\*(C`perl \-V:d_setlocale\*(C'\fR will say that the value for \f(CW\*(C`d_setlocale\*(C'\fR is\&\f(CW\*(C`define\*(C'\fR..PPIf you want a Perl application to process and present your dataaccording to a particular locale, the application code should includethe \f(CW\*(C`use\ locale\*(C'\fR pragma (see \*(L"The use locale pragma\*(R") whereappropriate, and \fBat least one\fR of the following must be true:.IP "\(bu" 4\&\fBThe locale-determining environment variables (see \*(L"\s-1ENVIRONMENT\s0\*(R")must be correctly set up\fR at the time the application is started, eitherby yourself or by whoever set up your system account..IP "\(bu" 4\&\fBThe application must set its own locale\fR using the method described in\&\*(L"The setlocale function\*(R"..SH "USING LOCALES".IX Header "USING LOCALES".Sh "The use locale pragma".IX Subsection "The use locale pragma"By default, Perl ignores the current locale. The \f(CW\*(C`use\ locale\*(C'\fRpragma tells Perl to use the current locale for some operations:.IP "\(bu" 4\&\fBThe comparison operators\fR (\f(CW\*(C`lt\*(C'\fR, \f(CW\*(C`le\*(C'\fR, \f(CW\*(C`cmp\*(C'\fR, \f(CW\*(C`ge\*(C'\fR, and \f(CW\*(C`gt\*(C'\fR) andthe \s-1POSIX\s0 string collation functions \fIstrcoll()\fR and \fIstrxfrm()\fR use\&\f(CW\*(C`LC_COLLATE\*(C'\fR. \fIsort()\fR is also affected if used without anexplicit comparison function, because it uses \f(CW\*(C`cmp\*(C'\fR by default..Sp\&\fBNote:\fR \f(CW\*(C`eq\*(C'\fR and \f(CW\*(C`ne\*(C'\fR are unaffected by locale: they alwaysperform a char-by-char comparison of their scalar operands. What'smore, if \f(CW\*(C`cmp\*(C'\fR finds that its operands are equal according to thecollation sequence specified by the current locale, it goes on toperform a char-by-char comparison, and only returns \fI0\fR (equal) if theoperands are char-for-char identical. If you really want to know whethertwo strings\*(--which \f(CW\*(C`eq\*(C'\fR and \f(CW\*(C`cmp\*(C'\fR may consider different\*(--are equalas far as collation in the locale is concerned, see the discussion in\&\*(L"Category \s-1LC_COLLATE:\s0 Collation\*(R"..IP "\(bu" 4\&\fBRegular expressions and case-modification functions\fR (\fIuc()\fR, \fIlc()\fR,\&\fIucfirst()\fR, and \fIlcfirst()\fR) use \f(CW\*(C`LC_CTYPE\*(C'\fR.IP "\(bu" 4\&\fBThe formatting functions\fR (\fIprintf()\fR, \fIsprintf()\fR and \fIwrite()\fR) use\&\f(CW\*(C`LC_NUMERIC\*(C'\fR.IP "\(bu" 4\&\fBThe \s-1POSIX\s0 date formatting function\fR (\fIstrftime()\fR) uses \f(CW\*(C`LC_TIME\*(C'\fR..PP\&\f(CW\*(C`LC_COLLATE\*(C'\fR, \f(CW\*(C`LC_CTYPE\*(C'\fR, and so on, are discussed further in \&\*(L"\s-1LOCALE\s0 \s-1CATEGORIES\s0\*(R"..PPThe default behavior is restored with the \f(CW\*(C`no\ locale\*(C'\fR pragma, orupon reaching the end of block enclosing \f(CW\*(C`use locale\*(C'\fR..PPThe string result of any operation that uses localeinformation is tainted, as it is possible for a locale to beuntrustworthy. See \*(L"\s-1SECURITY\s0\*(R"..Sh "The setlocale function".IX Subsection "The setlocale function"You can switch locales as often as you wish at run time with the\&\fIPOSIX::setlocale()\fR function:.PP.Vb 2\& # This functionality not usable prior to Perl 5.004\& require 5.004;\&\& # Import locale\-handling tool set from POSIX module.\& # This example uses: setlocale \-\- the function call\& # LC_CTYPE \-\- explained below\& use POSIX qw(locale_h);\&\& # query and save the old locale\& $old_locale = setlocale(LC_CTYPE);\&\& setlocale(LC_CTYPE, "fr_CA.ISO8859\-1");\& # LC_CTYPE now in locale "French, Canada, codeset ISO 8859\-1"\&\& setlocale(LC_CTYPE, "");\& # LC_CTYPE now reset to default defined by LC_ALL/LC_CTYPE/LANG\& # environment variables. See below for documentation.\&\& # restore the old locale\& setlocale(LC_CTYPE, $old_locale);.Ve.PPThe first argument of \fIsetlocale()\fR gives the \fBcategory\fR, the second the\&\fBlocale\fR. The category tells in what aspect of data processing youwant to apply locale-specific rules. Category names are discussed in\&\*(L"\s-1LOCALE\s0 \s-1CATEGORIES\s0\*(R" and \*(L"\s-1ENVIRONMENT\s0\*(R". The locale is the name of acollection of customization information corresponding to a particularcombination of language, country or territory, and codeset. Read on forhints on the naming of locales: not all systems name locales as in theexample..PPIf no second argument is provided and the category is something elsethan \s-1LC_ALL\s0, the function returns a string naming the current locale
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -