case folding

pull/8757/head
Jacob Sandlund 2025-08-13 09:56:05 -04:00
parent f5a036a6a0
commit 341137ce2e
3 changed files with 13 additions and 7 deletions

View File

@ -42,8 +42,8 @@
.lazy = true, .lazy = true,
}, },
.uucode = .{ .uucode = .{
.url = "https://github.com/jacobsandlund/uucode/archive/96dd05cb9df893293fffe35321eb0aeb36379b48.tar.gz", .url = "https://github.com/jacobsandlund/uucode/archive/c7421d97dbdaa8aa176a87eb6dd7dcc3baab12d1.tar.gz",
.hash = "uucode-0.0.0-ZZjBPuZ1PAB3TAPIR1yzwyGZbAZ4AqYEtfQ81lsdBL67", .hash = "uucode-0.0.0-ZZjBPkh9PAAR34asa24LSw5i5TNKE1B3hohDkZL5iT8J",
}, },
.uucode_x = .{ .uucode_x = .{
.url = "https://github.com/jacobsandlund/uucode.x/archive/ca9a9a4560307a30319d206b1ac68a7fc2f2fce9.tar.gz", .url = "https://github.com/jacobsandlund/uucode.x/archive/ca9a9a4560307a30319d206b1ac68a7fc2f2fce9.tar.gz",

View File

@ -9,8 +9,11 @@ pub const tables = [_]config.Table{
.fields = &.{ .fields = &.{
wcwidth.field("wcwidth"), wcwidth.field("wcwidth"),
d.field("general_category"), d.field("general_category"),
d.field("has_emoji_presentation"),
d.field("block"), d.field("block"),
d.field("has_emoji_presentation"),
d.field("case_folding_full"),
// Alternative:
// d.field("case_folding_simple"),
}, },
}, },
}; };

View File

@ -6,7 +6,6 @@ const std = @import("std");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const assert = std.debug.assert; const assert = std.debug.assert;
const build_config = @import("../build_config.zig"); const build_config = @import("../build_config.zig");
const ziglyph = @import("ziglyph");
const uucode = @import("uucode"); const uucode = @import("uucode");
const key = @import("key.zig"); const key = @import("key.zig");
const KeyEvent = key.KeyEvent; const KeyEvent = key.KeyEvent;
@ -1566,6 +1565,8 @@ pub const Trigger = struct {
.unicode => |cp| std.hash.autoHash( .unicode => |cp| std.hash.autoHash(
hasher, hasher,
foldedCodepoint(cp), foldedCodepoint(cp),
// Alternative, just use simple case folding:
// uucode.get(.case_folding_simple, cp),
), ),
} }
std.hash.autoHash(hasher, self.mods.binding()); std.hash.autoHash(hasher, self.mods.binding());
@ -1576,14 +1577,16 @@ pub const Trigger = struct {
fn foldedCodepoint(cp: u21) [3]u21 { fn foldedCodepoint(cp: u21) [3]u21 {
// ASCII fast path // ASCII fast path
if (uucode.ascii.isAlphabetic(cp)) { if (uucode.ascii.isAlphabetic(cp)) {
return .{ ziglyph.letter.toLower(cp), 0, 0 }; return .{ uucode.ascii.toLower(cp), 0, 0 };
} }
// Unicode slow path. Case folding can resultin more codepoints. // Unicode slow path. Case folding can result in more codepoints.
// If more codepoints are produced then we return the codepoint // If more codepoints are produced then we return the codepoint
// as-is which isn't correct but until we have a failing test // as-is which isn't correct but until we have a failing test
// then I don't want to handle this. // then I don't want to handle this.
return ziglyph.letter.toCaseFold(cp); var folded: [3]u21 = .{ 0, 0, 0 };
_ = uucode.get(.case_folding_full, cp).copy(&folded, cp);
return folded;
} }
/// Convert the trigger to a C API compatible trigger. /// Convert the trigger to a C API compatible trigger.