add utf8proc so we can detect unicode char width

This commit is contained in:
Mitchell Hashimoto
2022-08-20 10:48:54 -07:00
parent e83262e48e
commit 32d96dd49b
6 changed files with 71 additions and 0 deletions

8
pkg/utf8proc/main.zig Normal file
View File

@@ -0,0 +1,8 @@
pub const c = @import("c.zig");
/// Given a codepoint, return a character width analogous to `wcwidth(codepoint)`,
/// except that a width of 0 is returned for non-printable codepoints
/// instead of -1 as in `wcwidth`.
pub fn charwidth(codepoint: u21) u8 {
return @intCast(u8, c.utf8proc_charwidth(@intCast(i32, codepoint)));
}