Format a locale-specific string
Formatting function | Unformatted form: ESQL/C internal representation | Unformatted form: DataBlade API internal representation | Formatted form |
---|---|---|---|
ifx_gl_format_number() | decimal (dec_t) | mi_decimal | Number string |
ifx_gl_format_money() | decimal (dec_t) | mi_decimal | Money string |
ifx_gl_format_date() | date (long int) | mi_date | Date string |
ifx_gl_format_datetime() | datetime (dtime_t) | mi_datetime | Date/time string |
The formatting directives in the format string tell the formatting functions how to format the internal representation of a value into a locale-specific string. To process a formatting directive, a formatting function consults the appropriate category in the current locale to obtain any locale-specific formats and then formats the locale-specific string with this information.
mi_decimal num_val;
char num_str[BUFSIZE];
...
if ( ifx_gl_format_number(num_str, BUFSIZE, &num_val,"%0x") != 0 )
/* handle error */
If the current locale is the default locale, num_str contains the number string "1,450" upon successful completion of this call to ifx_gl_format_number(). The function correctly formats the comma (,) as the thousands separator in the number string.
If the current locale is French (fr_fr), the thousands separator is a space. Therefore, the preceding call to the function ifx_gl_convert_number() would format the French number string as "1 450".