Locale-specific numeric formatting

The HCL OneDB™ ESQL/C numeric-format functions require a format string as an argument.

This format string determines how the numeric-format function formats the numeric value. A format string consists of a series of formatting characters and the following currency notation.
Formatting character Function
Dollar sign ($) Currency symbol
Comma (,) Thousands separator
Period (.) Decimal separator
Regardless of the client locale that you use, you must use the preceding ASCII symbols in the format string to identify where to place the currency symbol, decimal separator, and thousands separator. The numeric-format function uses the following precedence to translate these symbols to their locale-specific equivalents:
  1. The symbols that DBMONEY indicates (if DBMONEY is set)

    For information about the locale-specific behavior of DBMONEY, see DBMONEY extensions.

  2. The symbols that the appropriate locale category of the client locale (if CLIENT_LOCALE is set) specifies

    If the format string contains either a $ or @ formatting character, a numeric-format function assumes that the value is a monetary value and refers to the MONETARY category of the client locale. If these two symbols are not in the format string, a numeric-format function refers to the NUMERIC category of the client locale.

    For more information about the use of the $ and @ formatting characters, see ids_gug_236.html#ids_gug_236. For more information about the MONETARY and NUMERIC locale categories, see Locale categories.

  3. The actual symbol that appears in the format string ($, comma, or period)

These numeric-format functions replace the dollar sign in the format string with the currency symbol that DBMONEY specifies (if it is set) or with the currency symbol that the client locale specifies (if DBMONEY is not set).

The same is true for the decimal separator and thousands separator. For example, the following HCL OneDB ESQL/C code fragment shows a call to the rfmtlong() function:
stcopy("$***,***.&&", fmtbuf);
rfmtlong(78941, fmtbuf, outbuf);
printf("Formatted value: %s\n", outbuf);
In the default, German, and Spanish locales, this code fragment produces the following results for the logical MONEY value of 78941.00 (if DBMONEY is not set).
Format string Client locale Formatted Value
$***,***.&& Default locale (en_us.8859-1) $*78,941.00
German locale (de_de.8859-1) DM*78.941,00
Spanish locale (es_es.8859-1) Pts*78.941,00

In the default locale, this code fragment produces the following result for the logical MONEY value of 78941.00 (if DBMONEY is not set): $*78,941.00