authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-10-16 04:17:39 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2024-10-16 04:17:39 -07:00
logee603105290e5f53ef15182b921c8eb48b9b0a0b
tree87154bc636c46695069ea1fbb72752bcbf6d934a
parentab91c7909f771c790977c0b0b8fa53a025e280ce

add eastAsianWidth


2 files changed, 11 insertions(+), 1 deletions(-)

src/main.zig+1-1
...@@ -87,7 +87,7 @@ export fn u_hasBinaryProperty(cp: u32, prop: t.UProperty) bool {...@@ -87,7 +87,7 @@ export fn u_hasBinaryProperty(cp: u32, prop: t.UProperty) bool {
87 .UCHAR_BLOCK => false, // TODO87 .UCHAR_BLOCK => false, // TODO
88 .UCHAR_CANONICAL_COMBINING_CLASS => false, // TODO88 .UCHAR_CANONICAL_COMBINING_CLASS => false, // TODO
89 .UCHAR_DECOMPOSITION_TYPE => false, // TODO89 .UCHAR_DECOMPOSITION_TYPE => false, // TODO
90 .UCHAR_EAST_ASIAN_WIDTH => false, // TODO90 .UCHAR_EAST_ASIAN_WIDTH => icu.eastAsianWidth(cp) != null,
91 .UCHAR_GENERAL_CATEGORY => false, // TODO91 .UCHAR_GENERAL_CATEGORY => false, // TODO
92 .UCHAR_JOINING_GROUP => false, // TODO92 .UCHAR_JOINING_GROUP => false, // TODO
93 .UCHAR_JOINING_TYPE => false, // TODO93 .UCHAR_JOINING_TYPE => false, // TODO
src/root.zig+10
...@@ -47,3 +47,13 @@ pub fn age(cp: u32) [2]u8 {...@@ -47,3 +47,13 @@ pub fn age(cp: u32) [2]u8 {
47 }47 }
48 return .{ 0, 0 };48 return .{ 0, 0 };
49}49}
50
51pub fn eastAsianWidth(cp: u32) ?ucd.EastAsianWidth {
52 @setEvalBranchQuota(100_000);
53 inline for (ucd.east_asian_width.data) |item| {
54 if (cp >= item.from and cp <= item.to) {
55 return item.prop;
56 }
57 }
58 return null;
59}