- 論壇徽章:
- 0
|
Definition and Usage
定義和用法
The setlocale() function sets locale information.
setlocale()函數(shù)的作用是:設(shè)置場景信息。
Locale information is language, monetary, time and other information specific for a geographical area.
本地信息可以是指定的某個區(qū)域的語言、貨幣、時間以及其它的信息。
This function returns the current locale settings, or FALSE on failure.
如果這個函數(shù)成功執(zhí)行,將返回當前的場景屬性;如果執(zhí)行失敗,將返回False。
Syntax
語法
setlocale(constant,location)
Parameter參數(shù)
Description描述
constant
Required. Specifies what locale information should be set.
必要參數(shù)。指定需要設(shè)置的場景信息
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 – 字符分類和轉(zhuǎn)換(例如:將所有的字符轉(zhuǎn)換成小寫或大寫形式)
- LC_MESSAGES - System message formatting
LC_MESSAGES – 系統(tǒng)信息格式
- LC_MONETARY - Monetary/currency formatting
LC_MONETARY – 貨幣 / 通貨格式
- LC_NUMERIC - Numeric formatting
LC_NUMERIC – 數(shù)值格式
- 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.
必要參數(shù)。指定需要進行場景信息設(shè)置的國家或區(qū)域。它可以由一個字符串或一個數(shù)組組成。如果本地區(qū)域是一個數(shù)組,那么setlocale()函數(shù)將嘗試每 個數(shù)組元素直到它從中獲取有效的語言和區(qū)域代碼信息為止。如果一個區(qū)域處于不同操作系統(tǒng)中的不同名稱下,那么這個參數(shù)將非常有用。
Note: Here you can find
language and region codes
.
注意:你可以通過下面一個地址查詢:語言信息和區(qū)域代碼
Tips and Notes
提示和注意點
Note: The setlocale() function changes the locale only for the current script.
注意:setlocale()函數(shù)僅改變當前腳本程序中的場景。
Tip: The locale information can be set to system default with setlocale(LC_ALL,NULL)
提示:可以使用setlocale(LC_ALL,NULL)函數(shù)將場景信息設(shè)置為系統(tǒng)默認值。
Example
案例
In this example we will set the locale to US English and then back to default again:
在下面這個案例中,我們把場景設(shè)置成美國英語[US English]之后,再將轉(zhuǎn)會默認的場景信息:
The output of the code above will be:
上述代碼將輸出下面的結(jié)果:
English_United States.1252
Norwegian (Bokmål)_Norway.1252
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u3/93660/showart_2054018.html |
|