You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wc -m returns character count instead of byte count in C/POSIX locale #9712
GNU wc checks MB_CUR_MAX to determine whether to count bytes or multibyte characters. When MB_CUR_MAX == 1 (C/POSIX locale), it treats each byte as a character.
wc -m produces different output than GNU in C/POSIX locale environments, breaking compatibility for scripts and CI pipelines that rely on locale-dependent character counting.
Recommendations
Check MB_CUR_MAX (or equivalent locale detection in rust) before counting characters. If MB_CUR_MAX == 1, return byte count instead of UTF-8 character count to match GNU behavior.
I reran the original reproducer against GNU wc 9.4 and current uutils main:
printf'한글'| LC_ALL=C wc -m
Both now return 6 (uutils previously returned 2).
also compared main against #11006 across the tested locale/counting combinations and found no behavioral diff
the ref to this issue in #15254 predates the merge of #16087. Other wc divergences remain, but the specific C/POSIX wc -m issue reported here is resolved
Activity
alexandrefresnais commentedon Dec 21, 2025
After a quick look, I am not really sure how we can properly access
MB_CUR_MAXfromlibc. Any idea ?sylvestre commentedon Jan 17, 2026
@alexandrefresnais maybe ? :)
fix(wc): respect C/POSIX locale for character counting
fix(wc): respect C/POSIX locale for character counting
fix(wc): respect C/POSIX locale for character counting
wc: respect C/POSIX locale for character counting
wc: respect C/POSIX locale for character counting
wc: respect C/POSIX locale for character counting
wc: respect C/POSIX locale for character counting
naoNao89 commentedon Nov 20, 2026
this appears to be fixed by #16087
I reran the original reproducer against GNU wc 9.4 and current uutils main:
Both now return
6(uutils previously returned2).also compared main against #11006 across the tested locale/counting combinations and found no behavioral diff
the ref to this issue in #15254 predates the merge of #16087. Other
wcdivergences remain, but the specific C/POSIXwc -missue reported here is resolvedithink this can be closed as fixed #16087
xtqqczze commentedon Nov 25, 2026
Fixed in v0.13.0.