From 3b7f5af0427410a7a225f622e67eb9b8a2a1a6a6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 13 Nov 2021 22:03:22 -0500 Subject: LibUnicode: Generate primary and secondary number grouping sizes Most locales have a single grouping size (the number of integer digits to be written before inserting a grouping separator). However some have a primary and secondary size. We parse the primary size as the size used for the least significant integer digits, and the secondary size for the most significant. --- Userland/Libraries/LibUnicode/Forward.h | 1 + Userland/Libraries/LibUnicode/Locale.cpp | 9 +++++++++ Userland/Libraries/LibUnicode/Locale.h | 6 ++++++ 3 files changed, 16 insertions(+) (limited to 'Userland/Libraries/LibUnicode') diff --git a/Userland/Libraries/LibUnicode/Forward.h b/Userland/Libraries/LibUnicode/Forward.h index 5015f324b1..b18426ce34 100644 --- a/Userland/Libraries/LibUnicode/Forward.h +++ b/Userland/Libraries/LibUnicode/Forward.h @@ -30,6 +30,7 @@ struct ListPatterns; struct LocaleExtension; struct LocaleID; struct NumberFormat; +struct NumberGroupings; struct OtherExtension; struct SpecialCasing; struct TransformedExtension; diff --git a/Userland/Libraries/LibUnicode/Locale.cpp b/Userland/Libraries/LibUnicode/Locale.cpp index 2080783399..d66544d0fe 100644 --- a/Userland/Libraries/LibUnicode/Locale.cpp +++ b/Userland/Libraries/LibUnicode/Locale.cpp @@ -824,6 +824,15 @@ Optional get_number_system_symbol([[maybe_unused]] StringView locale #endif } +Optional get_number_system_groupings([[maybe_unused]] StringView locale, [[maybe_unused]] StringView system) +{ +#if ENABLE_UNICODE_DATA + return Detail::get_number_system_groupings(locale, system); +#else + return {}; +#endif +} + Vector get_compact_number_system_formats([[maybe_unused]] StringView locale, [[maybe_unused]] StringView system, [[maybe_unused]] CompactNumberFormatType type) { #if ENABLE_UNICODE_DATA diff --git a/Userland/Libraries/LibUnicode/Locale.h b/Userland/Libraries/LibUnicode/Locale.h index 9e328b2738..32e115a756 100644 --- a/Userland/Libraries/LibUnicode/Locale.h +++ b/Userland/Libraries/LibUnicode/Locale.h @@ -85,6 +85,11 @@ enum class Style : u8 { Numeric, }; +struct NumberGroupings { + u8 primary_grouping_size { 0 }; + u8 secondary_grouping_size { 0 }; +}; + enum class StandardNumberFormatType : u8 { Decimal, Currency, @@ -181,6 +186,7 @@ Optional get_locale_script_mapping(StringView locale, StringView scr Optional get_locale_currency_mapping(StringView locale, StringView currency, Style style); Vector get_locale_key_mapping(StringView locale, StringView keyword); Optional get_number_system_symbol(StringView locale, StringView system, StringView symbol); +Optional get_number_system_groupings(StringView locale, StringView system); Optional get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type); Vector get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type); Optional get_locale_list_patterns(StringView locale, StringView type, StringView style); -- cgit v1.2.3