From 5edd4584206405a300209592ceb3edf65fed34e7 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 4 Aug 2021 07:05:30 -0400 Subject: [PATCH] LibUnicode: Parse UCD ScriptExtensions.txt and generate property --- .../Libraries/LibUnicode/CharacterTypes.cpp | 21 ++++++++ .../Libraries/LibUnicode/CharacterTypes.h | 1 + .../CodeGenerators/GenerateUnicodeData.cpp | 48 ++++++++++++++----- .../Libraries/LibUnicode/unicode_data.cmake | 11 ++++- 4 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Userland/Libraries/LibUnicode/CharacterTypes.cpp b/Userland/Libraries/LibUnicode/CharacterTypes.cpp index f780b319730..114cfb1c611 100644 --- a/Userland/Libraries/LibUnicode/CharacterTypes.cpp +++ b/Userland/Libraries/LibUnicode/CharacterTypes.cpp @@ -340,4 +340,25 @@ bool code_point_has_script([[maybe_unused]] u32 code_point, [[maybe_unused]] Scr #endif } +bool code_point_has_script_extension([[maybe_unused]] u32 code_point, [[maybe_unused]] Script script) +{ +#if ENABLE_UNICODE_DATA + auto unicode_data = Detail::unicode_data_for_code_point(code_point); + if (!unicode_data.has_value()) + return false; + + if (unicode_data->script == script) + return true; + + for (u32 i = 0; i < unicode_data->script_extensions_size; ++i) { + if (unicode_data->script_extensions[i] == script) + return true; + } + + return false; +#else + return false; +#endif +} + } diff --git a/Userland/Libraries/LibUnicode/CharacterTypes.h b/Userland/Libraries/LibUnicode/CharacterTypes.h index 99f7846b09c..5651632f47b 100644 --- a/Userland/Libraries/LibUnicode/CharacterTypes.h +++ b/Userland/Libraries/LibUnicode/CharacterTypes.h @@ -30,5 +30,6 @@ bool is_ecma262_property(Property); Optional