Fixed the .len

This commit is contained in:
drust 2024-02-19 03:26:08 +00:00 committed by Tim Culverhouse
parent 8d0f73e951
commit 6461e6719c

View file

@ -30,7 +30,7 @@ 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) 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.replace(u8, str, "\u{200D}", "", &out);
return gwidth(out[0..n], .unicode); return gwidth(out[0..n], .unicode);
}, },