diff --git a/src/main.zig b/src/main.zig index 559241f5046d9e0ba34cf58b2c2c15e2a6dd9df0..5263236978eb9e2d73a9fa5f31e7909422bc9806 100644 --- a/src/main.zig +++ b/src/main.zig @@ -65,14 +65,14 @@ export fn u_hasBinaryProperty(cp: u32, prop: t.UProperty) bool { .UCHAR_CHANGES_WHEN_CASEFOLDED => icu.hasDerivedCoreProperty(cp, .Changes_When_Casefolded), .UCHAR_CHANGES_WHEN_CASEMAPPED => icu.hasDerivedCoreProperty(cp, .Changes_When_Casemapped), .UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED => false, // TODO - .UCHAR_EMOJI => false, // TODO - .UCHAR_EMOJI_PRESENTATION => false, // TODO - .UCHAR_EMOJI_MODIFIER => false, // TODO - .UCHAR_EMOJI_MODIFIER_BASE => false, // TODO - .UCHAR_EMOJI_COMPONENT => false, // TODO + .UCHAR_EMOJI => icu.hasEmojiCategory(cp, .Emoji), + .UCHAR_EMOJI_PRESENTATION => icu.hasEmojiCategory(cp, .Emoji_Presentation), + .UCHAR_EMOJI_MODIFIER => icu.hasEmojiCategory(cp, .Emoji_Modifier), + .UCHAR_EMOJI_MODIFIER_BASE => icu.hasEmojiCategory(cp, .Emoji_Modifier_Base), + .UCHAR_EMOJI_COMPONENT => icu.hasEmojiCategory(cp, .Emoji_Component), .UCHAR_REGIONAL_INDICATOR => icu.hasProperty(cp, .Regional_Indicator), .UCHAR_PREPENDED_CONCATENATION_MARK => false, // TODO - .UCHAR_EXTENDED_PICTOGRAPHIC => false, // TODO + .UCHAR_EXTENDED_PICTOGRAPHIC => icu.hasEmojiCategory(cp, .Extended_Pictographic), .UCHAR_BASIC_EMOJI => false, // TODO .UCHAR_EMOJI_KEYCAP_SEQUENCE => false, // TODO .UCHAR_RGI_EMOJI_MODIFIER_SEQUENCE => false, // TODO diff --git a/src/root.zig b/src/root.zig index 0ef7a1920afe2a284eb82eff05304449dd46d8d7..cff718f74aedf38e2900993f4bb24794763e06e2 100644 --- a/src/root.zig +++ b/src/root.zig @@ -24,3 +24,15 @@ pub fn hasProperty(cp: u32, comptime prop: ucd.prop_list.PropList.Property) bool } return false; } + +pub fn hasEmojiCategory(cp: u32, comptime cat: ucd.emoji.Emoji.Category) bool { + @setEvalBranchQuota(100_000); + inline for (ucd.emoji.data) |item| { + if (item.category == cat) { + if (cp >= item.from and cp <= item.to) { + return true; + } + } + } + return false; +}