Home  /  Autodocs

locale.library

FUNCTIONS

CloseCatalog CloseLocale ConvToLower ConvToUpper FormatDate
FormatString GetCatalogStr GetLocaleStr IsXXXX OpenCatalog
OpenLocale ParseDate StrConvert StrnCmp

NOTES

Starting with V40, locale.library maintains a global environment variable called "Language" which contains the name of the current default language as used in the system. This is the name of the language associated with the Locale structure returned by OpenLocale(NULL).

EXAMPLE

From a shell:

Echo "The system language currently is: $Language"

will print the name of the current system language ("english",
"français", etc)

NOTES

locale.library provides an ARexx function host interface that enables ARexx programs to take advantage of system localization. The functions provided by the interface are directly related to the functions described herein, with the differences mostly being in the way they are called.

The function host library vector is located at offset -30 from the library. This is the value you provide to ARexx in the AddLib() function call.

EXAMPLE

/* localetest.rexx */

/* Make sure locale is loaded as a function host */
IF ~SHOW(L,'locale.library') THEN DO
CALL ADDLIB('locale.library',0,-30)
END;

say ConvToLower("A");
say ConvToUpper("b");
say IsAlpha("1");

catalog = OpenCatalog("sys/workbench.catalog","english",0);
say GetCatalogStr(catalog,34,"default");
say CloseCatalog(catalog);
say StrnCmp("test","test",2);

NOTES

The Locale structure is the main public structure provided by locale.library. The structure is defined in <libraries/locale.h> and consists of the following fields:

loc_LocaleName (STRPTR)- Locale's name.

loc_LanguageName (STRPTR)
The language of the driver bound to this locale.

loc_PrefLanguages (STRPTR[10])
The ordered list of preferred languages for this locale.

loc_Flags (ULONG)
Locale flags. Currently always 0.

loc_CodeSet (ULONG)
Specifies the code set required by this locale. Before V46, this value was always 0. Since V46, this is the IANA charset number (see L:CharSets/character-sets). For compatibility, 0 should be handled as equal to 4, both meaning ISO-8859-1 Latin1.

loc_CountryCode (ULONG)
The international country code.

loc_TelephoneCode (ULONG)
The international telephone code for the country.

loc_GMTOffset (LONG)
The offset in minutes of the current location from GMT. Positive indicates a Westerly direction from GMT, negative Easterly.

loc_MeasuringSystem (UBYTE)
The measuring system being used.

loc_DateTimeFormat (STRPTR)
The date and time format string, ready to pass to FormatDate()

loc_DateFormat (STRPTR)
The date format string.

loc_TimeFormat (STRPTR)
The time format string.

loc_ShortDateTimeFormat (STRPTR) -

The short date and time format string, ready to pass to FormatDate()

loc_ShortDateFormat (STRPTR)
The short date format string.

loc_ShortTimeFormat (STRPTR)
The short time format string.

loc_DecimalPoint (STRPTR)
The decimal point character used to format non-monetary quantities.

loc_GroupSeparator (STRPTR)
The characters used to separate groups of digits before the decimal-point character in formatted non-monetary quantities.

loc_FracGroupSeparator (STRPTR)
The characters used to separate groups of digits after the decimal-point character in formatted non-monetary quantities.

loc_Grouping (STRPTR)
A string whose elements indicate the size of each group of digits before the decimal-point character in formatted non-monetary quantities.

loc_FracGrouping (STRPTR)
A string whose elements indicate the size of each group of digits after the decimal-point character in formatted non-monetary quantities.

loc_MonDecimalPoint (STRPTR)
The decimal-point used to format monetary quantities.

loc_MonGroupSeparator (STRPTR)
The separator for groups of digits before the decimal-point in monetary quantities.

loc_MonFracGroupSeparator (STRPTR)
The separator for groups of digits after the decimal-point in monetary quantities.

loc_MonGrouping (STRPTR)
A string whose elements indicate the size of each group of digits before the decimal-point character in monetary quantities.

loc_MonFracGrouping (STRPTR)
A string whose elements indicate the size of each group of digits after the decimal-point character in monetary quantities.

loc_MonFracDigits (UBYTE)
The number of fractional digits (those after the decimal-point) to be displayed in a formatted monetary quantity.

loc_MonIntFracDigits (UBYTE)
The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity.

loc_MonCS (STRPTR)
The local currency symbol applicable to the current locale.

loc_MonSmallCS (STRPTR)
The currency symbol for small amounts.

loc_MonIntCS (STRPTR)
The international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified in ISO 4217 Codes for the Representation of Currency and Funds. The fourth character (immediately preceding the NULL) is the character used to separate the international currency symbol from the monetary quantity.

loc_MonPositiveSign (STRPTR)
The string used to indicate a non-negative monetary quantity.

loc_MonPositiveSpaceSep (UBYTE)
Specifies the number of spaces separating the currency symbol from the non-negative monetary quantity.

loc_MonPositiveSignPos (UBYTE)
Set to a value indicating the positioning of loc_MonPositiveSign for a non-negative monetary quantity.

loc_MonPositiveCSPos (UBYTE)
Set to 1 or 0 if loc_MonCS respectively precedes or succeeds the value for a non-negative monetary quantity.

loc_MonNegativeSign (STRPTR)
The string used to indicate a negative monetary quantity.

loc_MonNegativeSpaceSep (UBYTE)
Specifies the number of spaces separating the currency symbol from the negative monetary quantity.

loc_MonNegativeSignPos (UBYTE)
Set to a value indicating the positioning of loc_MonNegativeSign for a negative monetary quantity.

loc_MonNegativeCSPos (UBYTE)
Set to 1 or 0 if loc_MonCS respectively precedes or succeeds the value for a negative monetary quantity.

The grouping tables pointed to by loc_Grouping, loc_FracGrounping, loc_MonGrouping, and loc_MonFracGrouping contain a stream of bytes with the following values:

The values of loc_MonPositiveSignPos and loc_MonNegativeSignPos are interpreted according to the following: