Tizen Native API
|
Functions | |
int | i18n_unumber_create (i18n_unumber_format_style_e style, const i18n_uchar *pattern, int32_t pattern_len, const char *locale, i18n_uparse_error_s *parse_err, i18n_unumber_format_h *num_format) |
Creates and returns a new unumber_format_h for formatting and parsing numbers. | |
int | i18n_unumber_destroy (i18n_unumber_format_h fmt) |
Destroys an i18n_unumber_format_h. | |
int | i18n_unumber_get_symbol (const i18n_unumber_format_h fmt, i18n_unumber_format_symbol_e symbol, i18n_uchar *buffer, int32_t size, int32_t *len_symbol) |
Gets a symbol associated with an i18n_unumber_format_h. |
The Unumber module helps you format and parse numbers for any locale.
#include <utils_i18n.h>
The Unumber module helps you format and parse numbers for any locale. Your code can be completely independent of the locale conventions for decimal points, thousands-separators, or even the particular decimal digits used, or whether the number format is even decimal. There are different number format styles like decimal, currency, percent and spellout.
Gets a currency symbol according to a given locale.
int buf_len; i18n_uchar u_buffer[64]; char a_buffer[64]; i18n_unumber_format_h num_format; // creates and returns a new unumber_format i18n_unumber_create(I18N_UNUMBER_CURRENCY, NULL, -1, "en_US", NULL, &num_format); // gets a symbol associated with i18n_unumber_format i18n_unumber_get_symbol(num_format, I18N_UNUMBER_CURRENCY_SYMBOL, u_buffer, 64, &buf_len); i18n_ustring_copy_au(a_buffer, u_buffer); // en_US currency symbol: $ dlog_print(DLOG_INFO, LOG_TAG, "en_US currency symbol: %s \n", a_buffer); // destroys i18n_unumber_format i18n_unumber_destroy(num_format);
Enumeration for the possible number format styles.
I18N_UNUMBER_PATTERN_DECIMAL |
Decimal format defined by a pattern string |
I18N_UNUMBER_DECIMAL |
Decimal format ("normal" style) |
I18N_UNUMBER_CURRENCY |
Currency format with a currency symbol, e.g., "$1.00" |
I18N_UNUMBER_PERCENT |
Percent format |
I18N_UNUMBER_SCIENTIFIC |
Scientific format |
I18N_UNUMBER_SPELLOUT |
Spellout rule-based format |
I18N_UNUMBER_ORDINAL |
Ordinal rule-based format |
I18N_UNUMBER_DURATION |
Duration rule-based format |
I18N_UNUMBER_NUMBERING_SYSTEM |
Numbering system rule-based format |
I18N_UNUMBER_PATTERN_RULEBASED |
Rule-based format defined by a pattern string |
I18N_UNUMBER_CURRENCY_ISO |
Currency format with an ISO currency code, e.g., "USD1.00" |
I18N_UNUMBER_CURRENCY_PLURAL |
Currency format with a pluralized currency name, e.g., "1.00 US dollar" and "3.00 US dollars" |
I18N_UNUMBER_FORMAT_STYLE_COUNT |
One more than the highest number format style constant |
I18N_UNUMBER_DEFAULT |
Default format |
I18N_UNUMBER_IGNORE |
Alias for I18N_UNUMBER_PATTERN_DECIMAL |
Enumeration of constants for specifying a number format symbol.
int i18n_unumber_create | ( | i18n_unumber_format_style_e | style, |
const i18n_uchar * | pattern, | ||
int32_t | pattern_len, | ||
const char * | locale, | ||
i18n_uparse_error_s * | parse_err, | ||
i18n_unumber_format_h * | num_format | ||
) |
Creates and returns a new unumber_format_h for formatting and parsing numbers.
A unumber_format_style_e may be used to format numbers by calling i18n_unumber_create(). The caller must call i18n_unumber_destroy() when done to release resources used by this object.
[in] | style | The type of number format to open: one of I18N_UNUMBER_DECIMAL, I18N_UNUMBER_CURRENCY, I18N_UNUMBER_PERCENT, I18N_UNUMBER_SCIENTIFIC, I18N_UNUMBER_SPELLOUT, I18N_UNUMBER_ORDINAL, I18N_UNUMBER_DURATION, I18N_UNUMBER_NUMBERING_SYSTEM, I18N_UNUMBER_PATTERN_RULEBASED, or I18N_UNUMBER_DEFAULT If I18N_UNUMBER_PATTERN_DECIMAL or I18N_UNUMBER_PATTERN_RULEBASED is passed then the number format is opened using the given pattern, which must conform to the syntax described in DecimalFormat or RuleBasedNumberFormat, respectively. |
[in] | pattern | A pattern specifying the format to use This parameter is ignored unless the style is I18N_UNUMBER_PATTERN_DECIMAL or I18N_UNUMBER_PATTERN_RULEBASED. |
[in] | pattern_len | The number of characters in the pattern, otherwise -1 if null-terminatedThis parameter is ignored unless the style is I18N_UNUMBER_PATTERN . |
[in] | locale | A locale identifier to use to determine formatting and parsing conventions, otherwise NULL to use the default locale. |
[in] | parse_err | A pointer to a i18n_unumber_uparse_error_h struct to receive the details of any parsing errors, otherwise NULL if no parsing error details are desired. |
[out] | num_format | A pointer to a newly created i18n_unumber_format_h, otherwise NULL if an error occurrs. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_unumber_destroy | ( | i18n_unumber_format_h | fmt | ) |
Destroys an i18n_unumber_format_h.
Once destroyed, an i18n_unumber_format may no longer be used.
[in] | fmt | The formatter to destroy |
I18N_ERROR_NONE | Successful |
int i18n_unumber_get_symbol | ( | const i18n_unumber_format_h | fmt, |
i18n_unumber_format_symbol_e | symbol, | ||
i18n_uchar * | buffer, | ||
int32_t | size, | ||
int32_t * | len_symbol | ||
) |
Gets a symbol associated with an i18n_unumber_format_h.
An i18n_unumber_format_h uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.
[in] | fmt | The formatter to query. |
[in] | symbol | The unumber_format_symbol_e constant for the symbol to get |
[out] | buffer | The string buffer that will receive the symbol string If it is NULL , then only the length of the symbol is returned. |
[in] | size | The size of the string buffer |
[out] | len_symbol | The length of the symbol The buffer is not modified if length >= size |
I18N_ERROR_NONE | Successful. |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |