locale 中文man页面

系统
locale 就是一系列语言文化规则. 它包括如下一些方面: 讯息的语言, 不同字符设置, 文字惯例, 等等. 程序需要能够判断其 locale 并根据适合于不同文化的要求来运行. 头文件 <locale.h> 声明了用于该项作业中的数据类型,函数和宏.

NAME(名称)

locale - 描述多语言支持  

SYNOPSIS(总览)

#include <locale.h>

DESCRIPTION(描述)

locale 就是一系列语言文化规则. 它包括如下一些方面: 讯息的语言, 不同字符设置, 文字惯例, 等等. 程序需要能够判断其 locale 并根据适合于不同文化的要求来运行.

头文件 <locale.h> 声明了用于该项作业中的数据类型,函数和宏.

它声明的函数有: setlocale() 用来设置当前 locale, localeconv() 用来获得数字格式方面的信息.

程序可能需要的本地化信息会有不同的种类; 它们都以宏的方式声明把它们当做 setlocale() 的***个参数来用, 就可以把其中一个设置为需要的 locale:

LC_COLLATE
这用来修改函数 strcoll()strxfrm() 的执行方式, 其中 strxfrm() 函数用来以本地化字母表进行字符串比较. 例如, 德国升半音的 s 排序为 "ss".
LC_CTYPE
修改字符处理分类函数如 isupper()toupper() 的执行方式, 还修改多字节字符函数如 mblen() 或者 wctomb() 的执行方式.
LC_MONETARY
修改由 localeconv() 返回的信息, 这些信息描述了数字, 以及诸如小数点和千进位逗号之类输出的常见格式的细节. 这些信息由函数 strfmon() 在内部调用.
LC_MESSAGES
修改显示的语言信息以及正值和负值的表达方式. GNU C-library包含: rpmatch() 函数用于方便地使用这些信息.
LC_NUMERIC
在考虑使用 locale 设置时,修改 printf()scanf() 函数族使用的信息.该信息也可以由 localeconv() 函数读取.
LC_TIME
修改 strftime() 函数的执行方式以显示适于当地格式的当前时间; 例如,欧洲的绝大部分地区使用的是 24 小时的时钟, 而美国则是 12 小时的时钟.
LC_ALL
上述所有的.

如果 setlocale() 的第二个参数为空, 则设置 , 为默认的locale,它通过以下几步来确定:

1.
如果有非空的环境变量 LC_ALL, 则使用 LC_ALL 的值.
2.
如果存在一个与上述列出的种类同名的环境变量并且其不为空, 则使用该分类的值.
3.
如果有非空的环境变量 LANG, 则使用 LANG 的值.

关于本地数字格式的值用于由 localeconv() 函数返回的 struct lconv , 其有以下声明:

struct lconv
{
/* 数码(非货币形式)信息. */

char *decimal_point; /* 小数点字符. */
char *thousands_sep; /* 千数的分隔符. */
/* 每个元素就是每组的阿拉伯数字;指数越高的元素在越左边.一个值为CHAR_MAX的元素表示不需继续
分组了.一个值为0的元素表示前面的字符用于所有更左边的组. */
char *grouping;

/* 货币信息. */

/* 前三个字符是ISO 4217定义的流通符号.
第四个字符是分隔符. 第五个字符是' '. */
char *int_curr_symbol;
char *currency_symbol; /* 当地货币符号. */
char *mon_decimal_point; /* 小数点字符. */
char *mon_thousands_sep; /* 千数的分隔符. */
char *mon_grouping; /* 如前述的'分组'元素. */
char *positive_sign; /* 正值符号. */
char *negative_sign; /* 负值符号. */
char int_frac_digits; /* 国际通用的数字. */
char frac_digits; /* 本地使用的数字. */
/* 如果currency_symbol后跟着一个正值则为1,如果顺序相反为0. */
char p_cs_precedes;
/* 如果在currency_symbol和正值之间是一个空格则为1. */
char p_sep_by_space;
/* 如果currency_symbol后跟着一个负值则为1,如果顺序相反为0. */
char n_cs_precedes;
/* 如果在currency_symbol和正值之间是一个空格则为1. */
char n_sep_by_space;
/* 正值和负值符号位置:
数量值和currency_symbol在圆括号内则为0.
符号字符串先于数量值和currency_symbol则为1.
符号字符串在数量值和currency_symbol之后则为2.
符号字符串后紧跟数量值和currency_symbol则为3.
符号字符串紧跟在数量值和currency_symbol之后则为4. */
char p_sign_posn;
char n_sign_posn;
};

CONFORMS TO(遵循规则)

POSIX.1  

SEE ALSO(另见)

setlocale(3), localeconv(3), locale(1), localedef(1), rpmatch(3), strfmon(3), strcoll(3), strxfrm(3), strftime(3)

#p#

NAME

locale - Description of multi-language support  

SYNOPSIS

#include <locale.h>

DESCRIPTION

A locale is a set of language and cultural rules. These cover aspects such as language for messages, different character sets, lexigraphic conventions, etc. A program needs to be able to determine its locale and act accordingly to be portable to different cultures.

The header <locale.h> declares data types, functions and macros which are useful in this task.

The functions it declares are setlocale() to set the current locale, and localeconv() to get information about number formatting.

There are different categories for local information a program might need; they are declared as macros. Using them as the first argument to the setlocale() function, it is possible to set one of these to the desired locale:

LC_COLLATE
This is used to change the behaviour of the functions strcoll() and strxfrm(), which are used to compare strings in the local alphabet. For example, the German sharp s is sorted as "ss".
LC_CTYPE
This changes the behaviour of the character handling and classification functions, such as isupper() and toupper(), and the multi-byte character functions such as mblen() or wctomb().
LC_MONETARY
changes the information returned by localeconv() which describes the way numbers are usually printed, with details such as decimal point versus decimal comma. This information is internally used by the function strfmon().
LC_MESSAGES
changes the language messages are displayed in and how an affirmative or negative answer looks like. The GNU C-library contains the gettext(), ngettext(), and rpmatch() functions to ease the use of these information. The GNU gettext family of functions also obey the environment variable LANGUAGE.
LC_NUMERIC
changes the information used by the printf() and scanf() family of functions, when they are advised to use the locale-settings. This information can also be read with the localeconv() function.
LC_TIME
changes the behaviour of the strftime() function to display the current time in a locally acceptable form; for example, most of Europe uses a 24-hour clock vs. the US' 12-hour clock.
LC_ALL
All of the above.

If the second argument to setlocale() is empty string, , for the default locale, it is determined using the following steps:

1.
If there is a non-null environment variable LC_ALL, the value of LC_ALL is used.
2.
If an environment variable with the same name as one of the categories above exists and is non-null, its value is used for that category.
3.
If there is a non-null environment variable LANG, the value of LANG is used.

Values about local numeric formatting is made available in a struct lconv returned by the localeconv() function, which has the following declaration:

struct lconv
{
  /* Numeric (non-monetary) information.  */

  char *decimal_point;          /* Decimal point character.  */
  char *thousands_sep;          /* Thousands separator.  */
  /* Each element is the number of digits in each group;
     elements with higher indices are farther left.
     An element with value CHAR_MAX means that no further grouping is done.
     An element with value 0 means that the previous element is used
     for all groups farther left.  */
  char *grouping;

  /* Monetary information.  */

  /* First three chars are a currency symbol from ISO 4217.
     Fourth char is the separator.  Fifth char is ' '.  */
  char *int_curr_symbol;
  char *currency_symbol;        /* Local currency symbol.  */
  char *mon_decimal_point;      /* Decimal point character.  */
  char *mon_thousands_sep;      /* Thousands separator.  */
  char *mon_grouping;           /* Like `grouping' element (above).  */
  char *positive_sign;          /* Sign for positive values.  */
  char *negative_sign;          /* Sign for negative values.  */
  char int_frac_digits;         /* Int'l fractional digits.  */
  char frac_digits;             /* Local fractional digits.  */
  /* 1 if currency_symbol precedes a positive value, 0 if succeeds.  */
  char p_cs_precedes;
  /* 1 if a space separates currency_symbol from a positive value.  */
  char p_sep_by_space;
  /* 1 if currency_symbol precedes a negative value, 0 if succeeds.  */
  char n_cs_precedes;
  /* 1 if a space separates currency_symbol from a negative value.  */
  char n_sep_by_space;
  /* Positive and negative sign positions:
     0 Parentheses surround the quantity and currency_symbol.
     1 The sign string precedes the quantity and currency_symbol.
     2 The sign string succeeds the quantity and currency_symbol.
     3 The sign string immediately precedes the currency_symbol.
     4 The sign string immediately succeeds the currency_symbol.  */
  char p_sign_posn;
  char n_sign_posn;
};

CONFORMS TO

POSIX.1

The GNU gettext functions are specified in LI18NUX2000.  

SEE ALSO

setlocale(3), localeconv(3), locale(1), localedef(1), nl_langinfo(3), gettext(3), ngettext(3), rpmatch(3), strfmon(3), strcoll(3), strxfrm(3), strftime(3)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-25 10:19:03

locale中文man

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:33:18

exit中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-23 17:24:11

userdel中文man

2011-08-23 17:33:22

rdev中文man

2011-08-23 18:05:21

ABORT中文man

2011-08-18 19:15:25

group中文man

2011-08-23 10:17:54

bdflush中文man

2011-08-23 10:48:03

exportfs中文man
点赞
收藏

51CTO技术栈公众号