Chinaunix首页 | 论坛 | 博客
  • 博客访问: 488079
  • 博文数量: 78
  • 博客积分: 5131
  • 博客等级: 大校
  • 技术积分: 1468
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-17 16:20
文章分类
文章存档

2012年(1)

2011年(29)

2010年(6)

2009年(24)

2008年(18)

我的朋友

分类: LINUX

2008-11-06 10:22:28

Definition and Usage
定义和用法

The setlocale() function sets locale information.
setlocale()函数的作用是:设置场景信息。

Locale information is language, monetary, time and other information specific for a geographical area.
本地信息可以是指定的某个区域的语言、货币、时间以及其它的信息。

This function returns the current locale settings, or FALSE on failure.
如果这个函数成功执行,将返回当前的场景属性;如果执行失败,将返回False。

Syntax
语法

setlocale(constant,location)

Parameter参数 Description描述
constant Required. Specifies what locale information should be set.
必要参数。指定需要设置的场景信息

Available constants:
可用的常量:

  • LC_ALL - All of the below
    LC_ALL – 所有下属的常量
  • LC_COLLATE - Sort order
    LC_COLLATE – 排列顺序
  • LC_CTYPE - Character classification and conversion (e.g. all characters should be lower or upper-case)
    LC_CTYPE – 字符分类和转换(例如:将所有的字符转换成小写或大写形式)
  • LC_MESSAGES - System message formatting
    LC_MESSAGES – 系统信息格式
  • LC_MONETARY - Monetary/currency formatting
    LC_MONETARY – 货币 / 通货格式
  • LC_NUMERIC - Numeric formatting
    LC_NUMERIC – 数值格式
  • LC_TIME - Date and time formatting
    LC_TIME – 日期和时间格式
location Required. Specifies what country/region to set the locale information to. Can be a string or an array. If the location is an array, setlocale() will try each array element until it finds a valid language or region code. This is very useful if a region is known under different names on different systems.
必要参数。指定需要进行场景信息设置的国家或区域。它可以由一个字符串或一个数组组成。如果本地区域是一个数组,那么setlocale()函数将尝试每 个数组元素直到它从中获取有效的语言和区域代码信息为止。如果一个区域处于不同操作系统中的不同名称下,那么这个参数将非常有用。

Note: Here you can find .
注意:你可以通过下面一个地址查询:语言信息和区域代码



Tips and Notes
提示和注意点

Note: The setlocale() function changes the locale only for the current script.
注意:setlocale()函数进改变当前脚本程序中的场景。

Tip: The locale information can be set to system default with setlocale(LC_ALL,NULL)
提示:可以使用setlocale(LC_ALL,NULL)函数将场景信息设置为系统默认值。


Example
案例

In this example we will set the locale to US English and then back to default again:
在下面这个案例中,我们把场景设置成美国英语[US English]之后,再将转会默认的场景信息:

echo setlocale(LC_ALL,"En-Us");
echo "
";
echo setlocale(LC_ALL,NULL);
?>

The output of the code above will be:
上述代码将输出下面的结果:

English_United States.1252
Norwegian (Bokm?l)_Norway.1252
阅读(2286) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~