Locale
structureThe Locale structure provides basic support for locale-dependent applications. In particular, it describes character sets and orderings on them, formats for monetary and numeric values, and special text formats for a given natural language. Note that locales are handled in an imperative fashion.
The semantics of the types and functions provided in Locale parallel those provided in the standard C libraries (cf. ANSI document X3.159-1989 or ISO/IEC [CITE]9899:1990/).
signature LOCALE
structure Locale
: LOCALE
eqtype category
val collate : category
val ctype : category
val monetary : category
val numeric : category
val time : category
val messages : category
exception NoSuchLocale
val getCategory : category -> string
val setCategory : (category * string) -> unit
val setLocale : string -> unit
type locale_state
val saveLocale : unit -> locale_state
val restoreLocale : locale_state -> unit
datatype sign_posn = PAREN | PREC_ALL | PREC_CUR | FOLLOW_ALL | FOLLOW_CURR
type lconv
val conventions : unit -> lconv
val decimalPoint : lconv -> char
val thousandsSep : lconv -> char option
val grouping : lconv -> int list
val currencySymbol : lconv -> string
val intCurrSymbol : lconv -> string
val monDecimalPoint : lconv -> char option
val monThousandsSep : lconv -> char option
val monGrouping : lconv -> int list
val positiveSign : lconv -> string
val negativeSign : lconv -> string
val intFracDigits : lconv -> int option
val fracDigits : lconv -> int option
val posCSPrecedes : lconv -> bool option
val posSepBySpace : lconv -> bool option
val negCSPrecedes : lconv -> bool option
val negSepBySpace : lconv -> bool option
val posSignPosn : lconv -> sign_posn option
val negSignPosn : lconv -> sign_posn option
exception NoSuchClass
eqtype char_class
val charClass : string -> char_class
val isClass : (WideChar.char * char_class) -> bool
eqtype category
collate
ctype
monetary
numeric
time
messages
exception NoSuchLocale
getCategory c
setCategory (c, s)
setLocale s
The locale "SML"
is the default SML locale, in which characters are 8 bits, character classification functions use ASCII ordering, etc. This locale is always supported. If s is the empty string, then the category is set in an implementation-specific manner. This usually involves reading the name of the locale from the environment. Other locales are optional.
The most common way to set the locale is to call setLocale ""
at the beginning of a program. This may fail, in which case application programs typically print a warning message and continue execution in the default "SML"
locale.
type locale_state
saveLocale ()
restoreLocale l
datatype sign_posn
PAREN
PREC_ALL
PREC_CUR
FOLLOW_ALL
FOLLOW_CURR
type lconv
conventions ()
decimalPoint l
Value in "SML"
locale: #"."
.
thousandsSep l
SOME c
where c is the character used in locale l to separate groups of digits in non-monetary quantities. Returns NONE if the locale does not have such a separator.
Value in "SML"
locale: NONE.
grouping l
thousandsSep l
, if defined. A list element of 0 indicates that the previous value is to be used repeatedly for the remainder of the digits. The end of the list indicates that no further grouping is to be performed. In particular, an empty list indicates that no grouping is to be performed.
Value in "SML"
locale: []
.
currencySymbol l
Value in "SML"
locale: ""
.
intCurrSymbol l
int_curr_symbol
field of the struct lconv
value returned by the ISO C function localeconv
.
Value in "SML"
locale: ""
.
monDecimalPoint l
SOME c
where c is the character used for a monetary decimal point in locale l; returns NONE if the locale does not have a monetary decimal point.
Value in "SML"
locale: NONE.
monThousandsSep l
SOME c
where c is the character used in locale l to separate groups of digits in monetary quantities. Returns NONE if the locale does not have such a separator.
Value in "SML"
locale: NONE.
monGrouping l
monThousandsSep l
, if defined. A list element of 0 indicates that the previous value is to be used repeatedly for the remainder of the digits. The end of the list indicates that no further grouping is to be performed. In particular, an empty list indicates that no grouping is to be performed.
Value in "SML"
locale: []
.
positiveSign l
Value in "SML"
locale: ""
.
negativeSign lc
Value in "SML"
locale: ""
.
intFracDigits l
SOME i
if locale l specifies the number of fractional digits i (those to the right of the decimal point) to be displayed in an internationally formatted monetary quantity.
Value in "SML"
locale: NONE.
fracDigits l
SOME i
if locale l specifies the number of fractional digits i (those to the right of the decimal point) to be displayed in an formatted monetary quantity.
Value in "SML"
locale: NONE.
posCSPrecedes l
SOME b
where b is true
if and only if the currency symbol precedes, versus follows, the value for a nonnegative formatted monetary quantity in locale l; returns NONE if this is unspecified for locale l.
Value in "SML"
locale: NONE.
posSepBySpace l
SOME b
where b is true
if and only if the currency symbol is separated by a space from the value for a nonnegative formatted monetary quantity in locale l; returns NONE if this is unspecified for locale l.
Value in "SML"
locale: NONE.
negCSPrecedes l
SOME b
where b is true
if and only if the currency symbol precedes, versus follows, the value for a negative formatted monetary quantity in locale l; returns NONE if this is unspecified for locale l.
Value in "SML"
locale: NONE.
negSepBySpace l
SOME b
where b is true
if and only if the currency symbol is separated by a space from the value for a negative formatted monetary quantity in locale l; returns NONE if this is unspecified for locale l.
Value in "SML"
locale: NONE.
posSignPosn l
SOME p
where p is the position of the positive sign for a nonnegative formatted monetary quantity for locale l; returns NONE if this is unspecified for locale l.
Value in "SML"
locale: NONE.
negSignPosn l
SOME p
where p is the position of the negative sign for a negative formatted monetary quantity for locale l; returns NONE if this is unspecified for locale l.
Value in "SML"
locale: NONE.
exception NoSuchClass
eqtype char_class
charClass s
A char_class value must encapsulate information concerning the current locale, so that its use in isClass is independent of any change to the global current locale.
The standard classes "alnum"
, "alpha"
, "blank"
, "cntrl"
, "digit"
, "graph"
, "lower"
, "print"
, "punct"
, "space"
, "upper"
and "xdigit"
are always provided.
isClass (c, cc)
true
if c is in the locale-dependent character class denoted by cc.
For the standard character classes (except "blank"
), isClass is equivalent to the specific form described in CHAR, e.g., isClass(c, charClass "alpha")
is the same as WideChar.isAlpha c
.
Question:
This function should be moved somewhere else.
MultiByte, WideChar, WideSubstring
Last Modified January 21, 1997
Comments to John Reppy.
Copyright © 1997 Bell Labs, Lucent Technologies