Skip to content

ui::NumberFormatSymbols

Header: winui/core/NumberFormat.hpp.

The separators and digit grouping a locale writes a number with, as a DecimalFormatter uses them. The defaults are the locale-independent ones: "." for decimals, "," between groups of 3.

Example:

// An invoice for a German customer, written the same whatever the user's own locale is.
const ui::DecimalFormatter german{
    .fraction_digits = 2,
    .is_grouped      = true,
    .symbols         = ui::NumberFormatSymbols{.decimal_separator = ",", .grouping_separator = "."},
};
window.set_content(ui::Text{.text = "Summe: " + german.format(1234567.5) + " EUR"}); // "Summe: 1.234.567,50 EUR"

decimal_separator

std::string decimal_separator = "."

The decimal separator: "." (en-US), "," (de-DE, fr-FR).

grouping_separator

std::string grouping_separator = ","

The grouping separator: "," (en-US), "." (de-DE), U+202F (fr-FR), U+2019 (de-CH).

group_sizes

std::vector<int> group_sizes {3}

The group sizes from the decimal separator leftward: {3} is 1,234,567, and {3, 2} is 12,34,567 (hi-IN). The last size repeats unless repeat_last_group is false.

repeat_last_group

bool repeat_last_group = true

Whether the last entry of group_sizes repeats for the remaining digits; false leaves the digits beyond the listed groups ungrouped.

invariant

static NumberFormatSymbols invariant()

The locale-independent symbols, the default.