summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibUnicode
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-11-13 22:03:22 -0500
committerLinus Groh <mail@linusgroh.de>2021-11-14 10:35:19 +0000
commit3b7f5af0427410a7a225f622e67eb9b8a2a1a6a6 (patch)
tree2ec9591e345de1e0d3bde4b6a1c95f6823c062a5 /Userland/Libraries/LibUnicode
parent0e5983e6033cad65e86e74489e519c185a4c5116 (diff)
downloadserenity-3b7f5af0427410a7a225f622e67eb9b8a2a1a6a6.zip
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.
Diffstat (limited to 'Userland/Libraries/LibUnicode')
-rw-r--r--Userland/Libraries/LibUnicode/Forward.h1
-rw-r--r--Userland/Libraries/LibUnicode/Locale.cpp9
-rw-r--r--Userland/Libraries/LibUnicode/Locale.h6
3 files changed, 16 insertions, 0 deletions
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<StringView> get_number_system_symbol([[maybe_unused]] StringView locale
#endif
}
+Optional<NumberGroupings> 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<NumberFormat> 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<StringView> get_locale_script_mapping(StringView locale, StringView scr
Optional<StringView> get_locale_currency_mapping(StringView locale, StringView currency, Style style);
Vector<StringView> get_locale_key_mapping(StringView locale, StringView keyword);
Optional<StringView> get_number_system_symbol(StringView locale, StringView system, StringView symbol);
+Optional<NumberGroupings> get_number_system_groupings(StringView locale, StringView system);
Optional<NumberFormat> get_standard_number_system_format(StringView locale, StringView system, StandardNumberFormatType type);
Vector<NumberFormat> get_compact_number_system_formats(StringView locale, StringView system, CompactNumberFormatType type);
Optional<ListPatterns> get_locale_list_patterns(StringView locale, StringView type, StringView style);