理解本地语言环境变量

原出处:http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.nls/doc/nlsgdrf/locale_env.htm

Understanding Locale Environment Variables

National Language Support (NLS) uses several environment variables to influence the selection of locales. You can set the values of these variables to change search paths for locale information:

LANG
Specifies the installation default locale.
Note:
The   LANG  environment variable value is established at installation. (This is the locale every process uses unless the   LC_*  environment variables are set). The   LANG  environment variable can be changed by using the Manage Language Environment menu in SMIT. For more information about using SMIT, see   System Management Interface Tool (SMIT) Overview  in   Operating system and device management. The C and POSIX locales are designed to offer the best performance.
LC_ALL
Overrides the value of the   LANG  environment variable and the values of any other   LC_*  environment variables.
LC_COLLATE
Specifies the locale to use for   LC_COLLATE  category information. The   LC_COLLATE  category determines character-collation or string-collation rules governing the behavior of ranges, equivalence classes, and multicharacter collating elements.
LC_CTYPE
Specifies the locale to use for   LC_CTYPE  category information. The   LC_CTYPE  category determines character handling rules governing the interpretation of sequences of bytes of text data characters (that is, single-byte versus multibyte characters), the classification of characters (for example, alpha, digit, and so on), and the behavior of character classes.
LC__FASTMSG
Specifies that default messages are used for the C and POSIX locales and that   NLSPATH  are ignored when   LC__FASTMSG  is set to   true. Otherwise, POSIX compliant message handling will be performed. The default value will be   LC__FASTMSG=true  in the   /etc/environment  file.
LC_MESSAGES
Specifies the locale to use for   LC_MESSAGES  category information. The   LC_MESSAGES  category determines rules governing affirmative and negative responses and the locale (language) for messages and menus.

Application developers who write applications that do not display multibyte characters on a terminal should make sure the LC_MESSAGESvalue is not set to C@lft. If necessary, disable the setting with the putenv("LC_MESSAGES=") subroutine. The result is output that uses translated message catalogs. C@lft is disabled by login sessions that can display multibyte characters. Processes launched using cron orinittab retain the C@lft LC_MESSAGES value and use the setlocale() subroutine to establish the language environment for default messages.

LC_MONETARY
Specifies the locale to use for   LC_MONETARY  category information. The   LC_MONETARY  category determines the rules governing monetary-related formatting.
LC_NUMERIC
Specifies the locale to use for   LC_NUMERIC  category information. The   LC_NUMERIC  category determines the rules governing nonmonetary numeric formatting.
LC_TIME
Specifies the locale to use for   LC_TIME  category information. The   LC_TIME  category determines the rules governing date and time formatting.
LOCPATH
Specifies the search path for localized information, including binary locale files, input methods, and code-set converters.
Note:
All   setuid  and   setgid  programs ignore the   LOCPATH  environment variable.
NLSPATH
Specifies the search path for locating message catalog files. This environment variable is used by the Message Facility component of the NLS subsystem. See the   catopen  subroutine for more information about expected format of the   NLSPATH  variable.

The environment variables that affect locale selection can be grouped into three priority classes: high, medium, and low. Environment variables in the high priority class are:

  • LC_ALL
  • LC_COLLATE
  • LC_CTYPE

Environment variables in the medium priority class are:

  • LC_MESSAGES
  • LC_MONETARY
  • LC_NUMERIC
  • LC_TIME

The environment variable in the low priority class is:

  • LANG

When a locale is requested by the setlocale subroutine for a particular category or for all categories, the environment variable settings are queried by their priority level in the following manner:

  • If the LC_ALL environment variable is set, all six categories use the locale it specified. For example, if the LC_ALL environment variable is equal to en_US and the LANG environment variable is equal to fr_FR, a call to the setlocale subroutine sets each of the six categories to theen_US locale.
  • If the LC_ALL environment variable is not set, each individual category uses the locale specified by its corresponding environment variable. For example, if the LC_ALL environment variable is not set, the LC_COLLATE environment variable is set to de_DE, and the LC_TIME environment variable is set to fr_CA, then a call to the setlocale subroutine sets the LC_COLLATE category to de_DE and the LC_TIME category to fr_CA. Neither environment variable has precedence over the other in this situation.
  • If the LC_ALL environment variable is not set, and a value for a particular LC_* environment variable is not set, the value of the LANGenvironment variable determines the setting for that specific category. For example, if the LC_ALL environment variable is not set, theLC_CTYPE environment variable is set to en_US, the LC_NUMERIC environment variable is not set, and the LANG environment variable is set to is_IS, then a call to the setlocale subroutine sets the LC_CTYPE category to en_US and the LC_NUMERIC category to is_IS. The LANGenvironment variable specifies the locale for only those categories not previously determined by an LC_* environment variable.
  • If the LC_ALL environment variable is not set, a value for a particular LC_* environment variable is not set, and the value of the LANGenvironment variable is not set, the locale for that specific category defaults to the C locale. For example, if the LC_ALL environment variable is not set, the LC_MONETARY environment variable is set to sv_SE, the LC_TIME environment variable is not set, and the LANG environment variable is not set, then a call to the setlocale subroutine sets the LC_MONETARY category to sv_SE and the LC_TIME category to C.

Environment Variables Precedence Example

The following table shows the current setting of the environment variables and the effect of calling setlocale(LC_ALL,""). The last column indicates the locale setting after setlocale(LC_ALL,"") is called.

Environment Variable and Category Names Value of Environment Variables Value of Category After Call To setlocale(LC_ALL,"")
LC_COLLATE de_DE de_DE
LC_CTYPE de_DE de_DE
LC_MONETARY en_US en_US
LC_NUMERIC (unset) da_DK
LC_TIME (unset) da_DK
LC_MESSAGES (unset) da_DK
LC_ALL (unset) (not applicable)
LANG da_DK (not applicable)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值