From 8be1c82f57ccca32ca4b1789edee3bcc44efe671 Mon Sep 17 00:00:00 2001 From: "L.B.R." Date: Fri, 6 Nov 2026 17:26:26 +0000 Subject: [PATCH] docs(gwidth): state that ambiguous width is one column The comment in eawToWidth said that East Asian Ambiguous characters take two columns in an East Asian context, but the code returns one for them in every case. The code is right: glibc's wcwidth gives them one column in every UTF-8 locale, including ja, ko and zh, and most current terminals draw them narrow by default. A terminal can be set to draw them wide, but no environment variable reports that, so a locale-based guess would mismeasure text on the terminals that keep the default. Correct the comment so it matches the code and no longer suggests that ambiguous width depends on the locale. --- src/gwidth.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gwidth.zig b/src/gwidth.zig index 0cb1ae6..aa35b85 100644 --- a/src/gwidth.zig +++ b/src/gwidth.zig @@ -37,8 +37,10 @@ fn eawToWidth(cp: u21, eaw: uucode.types.EastAsianWidth) i16 { if (cp >= 0xe0100 and cp <= 0xe01ef) return 0; // Plane-14 variation selectors // East Asian Width: fullwidth or wide = 2 - // ambiguous in East Asian context = 2, otherwise 1 - // halfwidth, narrow, or neutral = 1 + // ambiguous, halfwidth, narrow, or neutral = 1 + // Ambiguous is 1 in every locale, as glibc's wcwidth also gives it. A + // terminal can be configured to draw ambiguous characters two columns + // wide, but nothing in the environment reports that setting. return switch (eaw) { .fullwidth, .wide => 2, else => 1, -- knotmirror 0.0.1