set_locale()

Set or get the value of a locale category.

Syntax

set_locale(category, locale)

Parameter

Parameter

Definition

category

locale categories Use ALL if you want to assign the default value to all locale categories. To use ALL, thelocale parameter must be "". For an explanation of locale categories, see PATROL Script Language Reference Manual Volume 1--PSL Essentials

Valid Values 
ALL, CTYPE, MESSAGES (or MESSAGE), TIME, CODECVT (or IO, OS)

locale

locale name Use "" to assign the default value to the locale category. Use 0 to return the current value of the locale category. Use a specific locale name to assign that name to the locale category. For an explanation of locale names, see PATROL Script Language Reference Manual Volume 1--PSL Essentials

Valid Values 
"", 0, supported locale names: C, ja_JP.CP932, ja_JP.eucJP, ja_JP.SJIS, ko_KR.eucKR, zh_CN.gb, zh_TW.big5, zh_TW.eucTW*Default Value* 
same as CTYPE locale category

Description

The set_locale() function sets or gets the value of a locale category. 

Note

This function provides support for internationalized PSL scripts. For more information about internationalization, seePATROL Script Language Reference Manual Volume 1 --PSL Essentials.

The value of the locale parameter determines whether set_locale() sets or gets a value. If you enter a specific locale name for locale, set_locale() tries to assign this locale name to the locale category specified by the category parameter. The set_locale() function returns 1 if it sets the category and 0 if it fails to set the value. If locale is 0, set_locale() returns the current value of category. If locale is "", set_locale() assigns the default value to category

If you use ALL as category, you are specifying all locale categories. You can use ALL with locale set only to "", which sets all categories to their default values. 

If category or locale is invalid, set_locale() sets the errno variable to 134 (E_PSL_SET_LOCALE_FAILED) and returns NULL. 

Note

You can't change the value of the CTYPE locale category.

Example

If a PATROL Agent is running under the ja_JP.eucJP locale, the following script shows how to read an SJIS-coded file and a eucJP-coded file.

set_locale("CODECVT", "ja_JP.SJIS");
data = cat("/home/users/text.sjis");
print(data);
set_locale("CODECVT", "");
data = cat("/home/users/text.euc");
print(data);

Where to go from here

PSL Built-in Functions

Was this page helpful? Yes No Submitting... Thank you

Comments