13
13
#include < LibUnicode/Locale.h>
14
14
15
15
#if ENABLE_UNICODE_DATA
16
+ # include < LibUnicode/UnicodeData.h>
16
17
# include < LibUnicode/UnicodeLocale.h>
17
18
# include < LibUnicode/UnicodeNumberFormat.h>
18
19
#endif
@@ -998,6 +999,7 @@ Optional<NumberFormat> select_currency_unit_pattern(StringView locale, StringVie
998
999
// https://www.unicode.org/reports/tr35/tr35-numbers.html#Currencies
999
1000
String create_currency_format_pattern (StringView currency_display, StringView base_pattern)
1000
1001
{
1002
+ #if ENABLE_UNICODE_DATA
1001
1003
constexpr auto number_key = " {number}" sv;
1002
1004
constexpr auto currency_key = " {currency}" sv;
1003
1005
constexpr auto spacing = " \u00A0 " sv; // No-Break Space (NBSP)
@@ -1008,17 +1010,14 @@ String create_currency_format_pattern(StringView currency_display, StringView ba
1008
1010
auto currency_index = base_pattern.find (currency_key);
1009
1011
VERIFY (currency_index.has_value ());
1010
1012
1011
- static auto symbol_category = general_category_from_string (" Symbol" sv);
1012
- VERIFY (symbol_category.has_value ()); // This shouldn't be reached if Unicode generation is disabled.
1013
-
1014
1013
Utf8View utf8_currency_display { currency_display };
1015
1014
Optional<String> currency_display_with_spacing;
1016
1015
1017
1016
if (*number_index < *currency_index) {
1018
1017
if (!base_pattern.substring_view (0 , *currency_index).ends_with (spacing)) {
1019
1018
u32 first_currency_code_point = *utf8_currency_display.begin ();
1020
1019
1021
- if (!code_point_has_general_category (first_currency_code_point, *symbol_category ))
1020
+ if (!code_point_has_general_category (first_currency_code_point, GeneralCategory::Symbol ))
1022
1021
currency_display_with_spacing = String::formatted (" {}{}" , spacing, currency_display);
1023
1022
}
1024
1023
} else {
@@ -1027,13 +1026,14 @@ String create_currency_format_pattern(StringView currency_display, StringView ba
1027
1026
for (auto it = utf8_currency_display.begin (); it != utf8_currency_display.end (); ++it)
1028
1027
last_currency_code_point = *it;
1029
1028
1030
- if (!code_point_has_general_category (last_currency_code_point, *symbol_category ))
1029
+ if (!code_point_has_general_category (last_currency_code_point, GeneralCategory::Symbol ))
1031
1030
currency_display_with_spacing = String::formatted (" {}{}" , currency_display, spacing);
1032
1031
}
1033
1032
}
1034
1033
1035
1034
if (currency_display_with_spacing.has_value ())
1036
1035
return base_pattern.replace (currency_key, *currency_display_with_spacing);
1036
+ #endif
1037
1037
1038
1038
return base_pattern.replace (currency_key, currency_display);
1039
1039
}
0 commit comments