From 5a232e0c3eaf08130652ed7fcea1146041252f0c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 29 Aug 2022 20:13:13 -0700 Subject: [PATCH] utf8proc: add grapheme break API --- pkg/utf8proc/main.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/utf8proc/main.zig b/pkg/utf8proc/main.zig index 31c54b545..3a8bbc11d 100644 --- a/pkg/utf8proc/main.zig +++ b/pkg/utf8proc/main.zig @@ -6,3 +6,13 @@ pub const c = @import("c.zig"); pub fn charwidth(codepoint: u21) u8 { return @intCast(u8, c.utf8proc_charwidth(@intCast(i32, codepoint))); } + +/// Given a pair of consecutive codepoints, return whether a grapheme break is +/// permitted between them (as defined by the extended grapheme clusters in UAX#29). +pub fn graphemeBreakStateful(cp1: u21, cp2: u21, state: *i32) bool { + return c.utf8proc_grapheme_break_stateful( + @intCast(i32, cp1), + @intCast(i32, cp2), + state, + ); +}