Jump to content

UniCreateLocaleObject: Difference between revisions

From EDM2
More to come later.
Finished it up
Line 52: Line 52:
If localeSpec is an empty character string (multi-byte or UCS), the locale object is initialized using the settings in the locale environment variables.
If localeSpec is an empty character string (multi-byte or UCS), the locale object is initialized using the settings in the locale environment variables.


Not completed.
<table cellpadding="7" cellspacing="0" border="0" width="100%">
<tr><th>Category</th><th>Precedence</th><th>Usage</th></tr>
<tr><td>[[OS2 API:Constant:LC#LC_ALL|LC_ALL]]</td><td>Highest</td><td>Setting [[OS2 API:Constant:LC#LC_ALL|LC_ALL]] takes precedence over any other locale environment variable.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LC_COLLATE|LC_COLLATE]]</td><td>Equal precedence</td><td>Specifies collation (sorting) rules.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LC_CTYPE|LC_CTYPE]]</td><td>Equal precedence</td><td>Specifies character classification and case conversion.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LC_MESSAGES|LC_MESSAGES]]</td><td>Equal precedence</td><td>Specifies the values for affirmative and negative answers, and the language for displayed messages.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LC_MONETARY|LC_MONETARY]]</td><td>Equal precedence</td><td>Specifies monetary formats and currency symbol.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LC_NUMERIC|LC_NUMERIC]]</td><td>Equal precedence</td><td>Specifies decimal formats.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LC_TIME|LC_TIME]]</td><td>Equal precedence</td><td>Specifies date and time formats.</td></tr>
<tr><td>[[OS2 API:Constant:LC#LANG|LANG]]</td><td>Lowest</td><td>Setting [[OS2 API:Constant:LC#LANG|LANG]] takes precedence over any undefined locale environment variable. This may be used in conjunction with [[OS2 API:Constant:LC#LC_COLLATE|LC_COLLATE]], [[OS2 API:Constant:LC#LC_CTYPE|LC_CTYPE]], [[OS2 API:Constant:LC#LC_MESSAGES|LC_MESSAGES]], [[OS2 API:Constant:LC#LC_MONETARY|LC_MONETARY]], [[OS2 API:Constant:LC#LC_NUMERIC|LC_NUMERIC]], and [[OS2 API:Constant:LC#LC_TIME|LC_TIME]].</td></tr>
</table>
 
If the specified locale is valid and supported, [[OS2 API:UniCreateLocaleObject|UniCreateLocaleObject]] allocates memory for the new object. It is the application's responsibility to free this memory with a call to [[OS2 API:UniFreeLocaleObject|UniFreeLocaleObject]] when the object is no longer needed. If the function fails for any reason, the contents localeObj are undefined.
 
The locale token provides a shorthand notation for specifying a locale. The format of the locale token is as returned by a call to [[OS2 API:UniLocaleStrToToken|UniLocaleStrToToken]]. The format is defined as an unsigned integer of four octets.
 
Examples of typical usage:
 
  1. The locale environment variables are set as follows:
 
      LANG=de_DE
      LC_MONETARY=en_US
 
      The localeSpec argument is an empty multibyte or UCS character string.
 
      This example creates a localeObj with all categories set to de_DE except for LC_MONETARY which has the value of en_US.
  2. The locale environment variables are set as follows:
 
      LANG=fr_FR
 
      The localeSpec argument is an empty multibyte or UCS character string.
 
      This example creates a locale object with all categories set to fr_FR.
  3. The locale environment variables are set as follows:
 
      LC_ALL=it_IT
      LANG=fr_FR
 
      The localeSpec argument is an empty multibyte or UCS character string.
 
      This example creates a locale object with all categories set to it_IT.


=== OS Version Introduced ===
=== OS Version Introduced ===
OS/2 Warp
OS/2 Warp

Revision as of 06:56, 22 August 2008

UniCreateLocaleObject

UniCreateLocaleObject(localeSpecType, localeSpec, result)
This function creates a locale object.

Parameters

localeSpecType - integer - input
Specifies the type of value of localeSpec.
localeSpec - PVOID - input
The specific type or locale token as defined by localeSpecType.
result - LocaleObject - output
The locale object for use.

Constants

The constants for use for localeSpecType:

Returns

An integer with values of:

Module

Define (C/C++)

Export name/Ordinal

Calling conversion

Cdecl32

Example Code

integer      localeSpecType;
PVOID        localeSpec;
LocaleObject localeObj;
integer      rc;
...
rc = UniCreateLocaleObject(localeSpecType, localeSpec, localeObj);
...

Related Functions

UniFreeLocaleObject

Notes

UniCreateLocaleObject create the locale object for the locale specified by localeSpec. The LocaleObject contains all the data and methods necessary to perform locale specific operations or accept the localeObj. Upon successful creation, all categories are created and initialized.

When localeSpec is a character string (multi-byte or UCS), it identifies the locale to be used for initialization. The locale name UNIV is reserved and refers to the definitions provide default behavior for functions.

If localeSpec is NULL, the locale name UNIV is used.

When localeSpec is a locale token as indicated by localeSpecType, the token identifies the locale to be initialized.

If localeSpec is an empty character string (multi-byte or UCS), the locale object is initialized using the settings in the locale environment variables.

CategoryPrecedenceUsage
LC_ALLHighestSetting LC_ALL takes precedence over any other locale environment variable.
LC_COLLATEEqual precedenceSpecifies collation (sorting) rules.
LC_CTYPEEqual precedenceSpecifies character classification and case conversion.
LC_MESSAGESEqual precedenceSpecifies the values for affirmative and negative answers, and the language for displayed messages.
LC_MONETARYEqual precedenceSpecifies monetary formats and currency symbol.
LC_NUMERICEqual precedenceSpecifies decimal formats.
LC_TIMEEqual precedenceSpecifies date and time formats.
LANGLowestSetting LANG takes precedence over any undefined locale environment variable. This may be used in conjunction with LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and LC_TIME.

If the specified locale is valid and supported, UniCreateLocaleObject allocates memory for the new object. It is the application's responsibility to free this memory with a call to UniFreeLocaleObject when the object is no longer needed. If the function fails for any reason, the contents localeObj are undefined.

The locale token provides a shorthand notation for specifying a locale. The format of the locale token is as returned by a call to UniLocaleStrToToken. The format is defined as an unsigned integer of four octets.

Examples of typical usage:

  1. The locale environment variables are set as follows:
     LANG=de_DE
     LC_MONETARY=en_US
     The localeSpec argument is an empty multibyte or UCS character string.
     This example creates a localeObj with all categories set to de_DE except for LC_MONETARY which has the value of en_US.
  2. The locale environment variables are set as follows:
     LANG=fr_FR
     The localeSpec argument is an empty multibyte or UCS character string.
     This example creates a locale object with all categories set to fr_FR.
  3. The locale environment variables are set as follows:
     LC_ALL=it_IT
     LANG=fr_FR
     The localeSpec argument is an empty multibyte or UCS character string.
     This example creates a locale object with all categories set to it_IT.

OS Version Introduced

OS/2 Warp