cs_locale

Description

Loads a CS_LOCALE structure with localization values or retrieve the locale name previously used to load a CS_LOCALE structure.

Syntax

CS_RETCODE cs_locale(context, action, locale, type,
                 buffer, buflen, outlen)
 
 CS_CONTEXT      *context;
 CS_INT                 action;
 CS_LOCALE         *locale;
 CS_INT                 type;
 CS_CHAR             *buffer;
 CS_INT                 buflen;
 CS_INT                 *outlen;

Parameters

context

A pointer to the CS_CONTEXT structure that represents the context in which the CS_LOCALE was allocated.

action

One of the following symbolic values:

Value of action

cs_locale

CS_SET

Loads the CS_LOCALE with new localization values.

CS_GET

Retrieves the locale name that was used to load the CS_LOCALE.

locale

A pointer to a CS_LOCALE structure. If action is CS_SET, cs_locale modifies this structure. If action is CS_GET, cs_locale examines the structure to determine the locale name that was previously used to load it.

type

One of the following symbolic values:

Value of type

Indicates

CS_LC_ALL

All types of localization information.

NoteCS_LC_ALL is “set only”; that is, action must be CS_SET when type is CS_LC_ALL.

CS_LC_COLLATE

The collating sequence (also called “sort order”). Open Client uses a collating sequence when sorting and comparing character data.

CS_LC_CTYPE

The character set. Open Client uses a character set when it converts to or from character datatypes.

CS_LC_MESSAGE

The language and character set to use for Open Client/Server and Adaptive Server error messages.

CS_LC_TIME

The language and character set to use when converting between datetime and character datatypes. CS_LC_TIME controls month names and abbreviations, datepart ordering, and whether the “am/pm” string is used.

CS_SYB_LANG, CS_SYB_CHARSET, CS_SYB_SORTORDER, CS_SYB_LANG_CHARSET

For information on these values, see “Using language, character set, and sort order names with cs_locale”.

WARNING! Open Server application programmers must set type to CS_LC_ALL when configuring the CS_LOCALE structure that applies to the Open Server application as a whole.

buffer

If action is CS_SET, buffer points to a character string that represents a locale name, a character set name, a language name, a sort order name, or a language/character set pair.

If action is CS_GET, buffer points to the space in which cs_locale will place a locale name, a character set name, a language name, a sort order name, or a language/character set pair. On output, all names are null-terminated. The buffer must be long enough for the name plus a null terminator.

buflen

The length, in bytes, of *buffer.

If action is CS_SET and the value in *buffer is null-terminated, pass buflen as CS_NULLTERM.

outlen

A pointer to an integer variable.

outlen is not used if action is CS_SET.

If action is CS_GET and outlen is supplied, cs_locale sets *outlen to the length, in bytes, of the locale name.

If the name is larger than buflen bytes, an application can use the value of *outlen to determine how many bytes are needed to hold the name.

If action is CS_SET or if an application does not require return length information, it can pass outlen as NULL.

Returns

cs_locale returns:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Common reasons for a cs_locale failure include:

Usage

Notecs_locale’s behavior depends on platform-specific configuration issues. You must read the localization chapter in the Open Client/Server Configuration Guide to obtain a full understanding of Client-Library’s localization mechanism. For a discussion of programming issues related to localization, see the Open Client/Server International Developer’s Guide.


Loading a CS_LOCALE structure


Retrieving a locale name


Using language, character set, and sort order names with cs_locale

See also

cs_loc_alloc, cs_loc_drop