⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perllocale.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 4 页
字号:
for the category.  You can use this value as the second argument in asubsequent call to \fIsetlocale()\fR..PPIf no second argument is provided and the category is \s-1LC_ALL\s0, theresult is implementation-dependent.  It may be a string ofconcatenated locales names (separator also implementation-dependent)or a single locale name.  Please consult your \fIsetlocale\fR\|(3) man page fordetails..PPIf a second argument is given and it corresponds to a valid locale,the locale for the category is set to that value, and the functionreturns the now-current locale value.  You can then use this in yetanother call to \fIsetlocale()\fR.  (In some implementations, the returnvalue may sometimes differ from the value you gave as the secondargument\*(--think of it as an alias for the value you gave.).PPAs the example shows, if the second argument is an empty string, thecategory's locale is returned to the default specified by thecorresponding environment variables.  Generally, this results in areturn to the default that was in force when Perl started up: changesto the environment made by the application after startup may or may notbe noticed, depending on your system's C library..PPIf the second argument does not correspond to a valid locale, the localefor the category is not changed, and the function returns \fIundef\fR..PPFor further information about the categories, consult \fIsetlocale\fR\|(3)..Sh "Finding locales".IX Subsection "Finding locales"For locales available in your system, consult also \fIsetlocale\fR\|(3) tosee whether it leads to the list of available locales (search for the\&\fI\s-1SEE\s0 \s-1ALSO\s0\fR section).  If that fails, try the following command lines:.PP.Vb 1\&        locale \-a\&\&        nlsinfo\&\&        ls /usr/lib/nls/loc\&\&        ls /usr/lib/locale\&\&        ls /usr/lib/nls\&\&        ls /usr/share/locale.Ve.PPand see whether they list something resembling these.PP.Vb 7\&        en_US.ISO8859\-1     de_DE.ISO8859\-1     ru_RU.ISO8859\-5\&        en_US.iso88591      de_DE.iso88591      ru_RU.iso88595\&        en_US               de_DE               ru_RU\&        en                  de                  ru\&        english             german              russian\&        english.iso88591    german.iso88591     russian.iso88595\&        english.roman8                          russian.koi8r.Ve.PPSadly, even though the calling interface for \fIsetlocale()\fR has beenstandardized, names of locales and the directories where theconfiguration resides have not been.  The basic form of the name is\&\fIlanguage_territory\fR\fB.\fR\fIcodeset\fR, but the latter parts after\&\fIlanguage\fR are not always present.  The \fIlanguage\fR and \fIcountry\fRare usually from the standards \fB\s-1ISO\s0 3166\fR and \fB\s-1ISO\s0 639\fR, thetwo-letter abbreviations for the countries and the languages of theworld, respectively.  The \fIcodeset\fR part often mentions some \fB\s-1ISO\s08859\fR character set, the Latin codesets.  For example, \f(CW\*(C`ISO 8859\-1\*(C'\fRis the so-called \*(L"Western European codeset\*(R" that can be used to encodemost Western European languages adequately.  Again, there are severalways to write even the name of that one standard.  Lamentably..PPTwo special locales are worth particular mention: \*(L"C\*(R" and \*(L"\s-1POSIX\s0\*(R".Currently these are effectively the same locale: the difference ismainly that the first one is defined by the C standard, the second bythe \s-1POSIX\s0 standard.  They define the \fBdefault locale\fR in whichevery program starts in the absence of locale information in itsenvironment.  (The \fIdefault\fR default locale, if you will.)  Its languageis (American) English and its character codeset \s-1ASCII\s0..PP\&\fB\s-1NOTE\s0\fR: Not all systems have the \*(L"\s-1POSIX\s0\*(R" locale (not all systems arePOSIX-conformant), so use \*(L"C\*(R" when you need explicitly to specify thisdefault locale..Sh "\s-1LOCALE\s0 \s-1PROBLEMS\s0".IX Subsection "LOCALE PROBLEMS"You may encounter the following warning message at Perl startup:.PP.Vb 6\&        perl: warning: Setting locale failed.\&        perl: warning: Please check that your locale settings:\&                LC_ALL = "En_US",\&                LANG = (unset)\&            are supported and installed on your system.\&        perl: warning: Falling back to the standard locale ("C")..Ve.PPThis means that your locale settings had \s-1LC_ALL\s0 set to \*(L"En_US\*(R" and\&\s-1LANG\s0 exists but has no value.  Perl tried to believe you but could not.Instead, Perl gave up and fell back to the \*(L"C\*(R" locale, the default localethat is supposed to work no matter what.  This usually means your localesettings were wrong, they mention locales your system has never heardof, or the locale installation in your system has problems (for example,some system files are broken or missing).  There are quick and temporaryfixes to these problems, as well as more thorough and lasting fixes..Sh "Temporarily fixing locale problems".IX Subsection "Temporarily fixing locale problems"The two quickest fixes are either to render Perl silent about anylocale inconsistencies or to run Perl under the default locale \*(L"C\*(R"..PPPerl's moaning about locale problems can be silenced by setting theenvironment variable \s-1PERL_BADLANG\s0 to a zero value, for example \*(L"0\*(R".This method really just sweeps the problem under the carpet: you tellPerl to shut up even when Perl sees that something is wrong.  Do notbe surprised if later something locale-dependent misbehaves..PPPerl can be run under the \*(L"C\*(R" locale by setting the environmentvariable \s-1LC_ALL\s0 to \*(L"C\*(R".  This method is perhaps a bit more civilizedthan the \s-1PERL_BADLANG\s0 approach, but setting \s-1LC_ALL\s0 (orother locale variables) may affect other programs as well, not justPerl.  In particular, external programs run from within Perl will seethese changes.  If you make the new settings permanent (read on), allprograms you run see the changes.  See \*(L"\s-1ENVIRONMENT\s0\*(R" forthe full list of relevant environment variables and \*(L"\s-1USING\s0 \s-1LOCALES\s0\*(R"for their effects in Perl.  Effects in other programs are easily deducible.  For example, the variable \s-1LC_COLLATE\s0 may well affectyour \fBsort\fR program (or whatever the program that arranges \*(L"records\*(R"alphabetically in your system is called)..PPYou can test out changing these variables temporarily, and if thenew settings seem to help, put those settings into your shell startupfiles.  Consult your local documentation for the exact details.  For inBourne-like shells (\fBsh\fR, \fBksh\fR, \fBbash\fR, \fBzsh\fR):.PP.Vb 2\&        LC_ALL=en_US.ISO8859\-1\&        export LC_ALL.Ve.PPThis assumes that we saw the locale \*(L"en_US.ISO8859\-1\*(R" using the commandsdiscussed above.  We decided to try that instead of the above faultylocale \*(L"En_US\*(R"\-\-and in Cshish shells (\fBcsh\fR, \fBtcsh\fR).PP.Vb 1\&        setenv LC_ALL en_US.ISO8859\-1.Ve.PPor if you have the \*(L"env\*(R" application you can do in any shell.PP.Vb 1\&        env LC_ALL=en_US.ISO8859\-1 perl ....Ve.PPIf you do not know what shell you have, consult your localhelpdesk or the equivalent..Sh "Permanently fixing locale problems".IX Subsection "Permanently fixing locale problems"The slower but superior fixes are when you may be able to yourselffix the misconfiguration of your own environment variables.  Themis(sing)configuration of the whole system's locales usually requiresthe help of your friendly system administrator..PPFirst, see earlier in this document about \*(L"Finding locales\*(R".  That tellshow to find which locales are really supported\*(--and more importantly,installed\*(--on your system.  In our example error message, environmentvariables affecting the locale are listed in the order of decreasingimportance (and unset variables do not matter).  Therefore, having\&\s-1LC_ALL\s0 set to \*(L"En_US\*(R" must have been the bad choice, as shown by theerror message.  First try fixing locale settings listed first..PPSecond, if using the listed commands you see something \fBexactly\fR(prefix matches do not count and case usually counts) like \*(L"En_US\*(R"without the quotes, then you should be okay because you are using alocale name that should be installed and available in your system.In this case, see \*(L"Permanently fixing your system's locale configuration\*(R"..Sh "Permanently fixing your system's locale configuration".IX Subsection "Permanently fixing your system's locale configuration"This is when you see something like:.PP.Vb 4\&        perl: warning: Please check that your locale settings:\&                LC_ALL = "En_US",\&                LANG = (unset)\&            are supported and installed on your system..Ve.PPbut then cannot see that \*(L"En_US\*(R" listed by the above-mentionedcommands.  You may see things like \*(L"en_US.ISO8859\-1\*(R", but that isn'tthe same.  In this case, try running under a localethat you can list and which somehow matches what you tried.  Therules for matching locale names are a bit vague becausestandardization is weak in this area.  See again the \&\*(L"Finding locales\*(R" about general rules..Sh "Fixing system locale configuration".IX Subsection "Fixing system locale configuration"Contact a system administrator (preferably your own) and report the exacterror message you get, and ask them to read this same documentation youare now reading.  They should be able to check whether there is somethingwrong with the locale configuration of the system.  The \*(L"Finding locales\*(R"section is unfortunately a bit vague about the exact commands and placesbecause these things are not that standardized..Sh "The localeconv function".IX Subsection "The localeconv function"The \fIPOSIX::localeconv()\fR function allows you to get particulars of thelocale-dependent numeric formatting information specified by the current\&\f(CW\*(C`LC_NUMERIC\*(C'\fR and \f(CW\*(C`LC_MONETARY\*(C'\fR locales.  (If you just want the name ofthe current locale for a particular category, use \fIPOSIX::setlocale()\fRwith a single parameter\*(--see \*(L"The setlocale function\*(R".).PP.Vb 1\&        use POSIX qw(locale_h);\&\&        # Get a reference to a hash of locale\-dependent info\&        $locale_values = localeconv();\&\&        # Output sorted list of the values\&        for (sort keys %$locale_values) {\&            printf "%\-20s = %s\en", $_, $locale_values\->{$_}\&        }.Ve.PP\&\fIlocaleconv()\fR takes no arguments, and returns \fBa reference to\fR a hash.The keys of this hash are variable names for formatting, such as\&\f(CW\*(C`decimal_point\*(C'\fR and \f(CW\*(C`thousands_sep\*(C'\fR.  The values are thecorresponding, er, values.  See \*(L"localeconv\*(R" in \s-1POSIX\s0 for a longerexample listing the categories an implementation might be expected toprovide; some provide more and others fewer.  You don't need anexplicit \f(CW\*(C`use locale\*(C'\fR, because \fIlocaleconv()\fR always observes thecurrent locale..PPHere's a simple-minded example program that rewrites its command-lineparameters as integers correctly formatted in the current locale:.PP.Vb 3\&        # See comments in previous example\&        require 5.004;\&        use POSIX qw(locale_h);\&\&        # Get some of locale\*(Aqs numeric formatting parameters\&        my ($thousands_sep, $grouping) =\&             @{localeconv()}{\*(Aqthousands_sep\*(Aq, \*(Aqgrouping\*(Aq};\&\&        # Apply defaults if values are missing\&        $thousands_sep = \*(Aq,\*(Aq unless $thousands_sep;\&\&        # grouping and mon_grouping are packed lists\&        # of small integers (characters) telling the\&        # grouping (thousand_seps and mon_thousand_seps\&        # being the group dividers) of numbers and\&        # monetary quantities.  The integers\*(Aq meanings:\&        # 255 means no more grouping, 0 means repeat\&        # the previous grouping, 1\-254 means use that\&        # as the current grouping.  Grouping goes from\&        # right to left (low to high digits).  In the\&        # below we cheat slightly by never using anything\&        # else than the first grouping (whatever that is).\&        if ($grouping) {\&            @grouping = unpack("C*", $grouping);\&        } else {\&            @grouping = (3);\&        }\&\&        # Format command line params for current locale\&        for (@ARGV) {\&            $_ = int;    # Chop non\-integer part\&            1 while\&            s/(\ed)(\ed{$grouping[0]}($|$thousands_sep))/$1$thousands_sep$2/;\&            print "$_";\&        }\&        print "\en";.Ve.Sh "I18N::Langinfo".IX Subsection "I18N::Langinfo"Another interface for querying locale-dependent information is the\&\fII18N::Langinfo::langinfo()\fR function, available at least in UNIX-likesystems and \s-1VMS\s0..PPThe following example will import the \fIlanginfo()\fR function itself andthree constants to be used as arguments to \fIlanginfo()\fR: a constant forthe abbreviated first day of the week (the numbering starts from

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -