1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:57:44 +00:00

Meta+LibUnicode: Download and parse Unicode block properties

This parses Blocks.txt for CharacterType properties and creates
a global display array for use in apps.
This commit is contained in:
thankyouverycool 2022-02-13 13:39:19 -05:00 committed by Tim Flynn
parent 32b8023ad1
commit 0505e031f1
5 changed files with 135 additions and 13 deletions

View file

@ -23,9 +23,11 @@
namespace Unicode {
Optional<String> __attribute__((weak)) code_point_display_name(u32) { return {}; }
Optional<StringView> __attribute__((weak)) code_point_block_display_name(u32) { return {}; }
Optional<StringView> __attribute__((weak)) code_point_abbreviation(u32) { return {}; }
u32 __attribute__((weak)) canonical_combining_class(u32) { return {}; }
Span<SpecialCasing const* const> __attribute__((weak)) special_case_mapping(u32) { return {}; }
Span<BlockName const> __attribute__((weak)) block_display_names() { return {}; }
#if ENABLE_UNICODE_DATA
@ -354,6 +356,9 @@ Optional<Script> __attribute__((weak)) script_from_string(StringView) { return {
bool __attribute__((weak)) code_point_has_script(u32, Script) { return {}; }
bool __attribute__((weak)) code_point_has_script_extension(u32, Script) { return {}; }
Optional<Block> __attribute__((weak)) block_from_string(StringView) { return {}; }
bool __attribute__((weak)) code_point_has_block(u32, Block) { return {}; }
bool __attribute__((weak)) code_point_has_grapheme_break_property(u32, GraphemeBreakProperty) { return {}; }
bool __attribute__((weak)) code_point_has_word_break_property(u32, WordBreakProperty) { return {}; }
bool __attribute__((weak)) code_point_has_sentence_break_property(u32, SentenceBreakProperty) { return {}; }

View file

@ -15,9 +15,22 @@
namespace Unicode {
struct CodePointRange {
u32 first { 0 };
u32 last { 0 };
};
struct BlockName {
CodePointRange code_point_range {};
StringView display_name;
};
Optional<String> code_point_display_name(u32 code_point);
Optional<StringView> code_point_block_display_name(u32 code_point);
Optional<StringView> code_point_abbreviation(u32 code_point);
Span<BlockName const> block_display_names();
u32 canonical_combining_class(u32 code_point);
Span<SpecialCasing const* const> special_case_mapping(u32 code_point);
@ -40,6 +53,9 @@ Optional<Script> script_from_string(StringView);
bool code_point_has_script(u32 code_point, Script script);
bool code_point_has_script_extension(u32 code_point, Script script);
Optional<Block> block_from_string(StringView);
bool code_point_has_block(u32 code_point, Block block);
bool code_point_has_grapheme_break_property(u32 code_point, GraphemeBreakProperty property);
bool code_point_has_word_break_property(u32 code_point, WordBreakProperty property);
bool code_point_has_sentence_break_property(u32 code_point, SentenceBreakProperty property);

View file

@ -10,6 +10,7 @@
namespace Unicode {
enum class Block : u16;
enum class Calendar : u8;
enum class CalendarFormatType : u8;
enum class CalendarPatternStyle : u8;