gwidth: fix gwidth for no_zwj case

This commit is contained in:
Tim Culverhouse 2024-03-19 13:20:00 -05:00
parent 15c64a0e66
commit 8a5fe1a8ab

View file

@ -31,7 +31,8 @@ pub fn gwidth(str: []const u8, method: Method) !usize {
.no_zwj => { .no_zwj => {
var out: [256]u8 = undefined; var out: [256]u8 = undefined;
if (str.len > out.len) return error.OutOfMemory; if (str.len > out.len) return error.OutOfMemory;
const n = std.mem.replace(u8, str, "\u{200D}", "", &out); const n = std.mem.replacementSize(u8, str, "\u{200D}", "");
_ = std.mem.replace(u8, str, "\u{200D}", "", &out);
return gwidth(out[0..n], .unicode); return gwidth(out[0..n], .unicode);
}, },
} }