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
Discrepancy in output length with special characters #5831
changed the title [-]Discrepancy in output length with special characters"[/-][+]Discrepancy in output length with special characters[/+]on Jan 13, 2024
I tried LC_ALL=C, LANG=C and LC_COLLATE=C, but no difference. And based on the doc of -L I would expect it to return 2 (and not 1) because there are two characters.
@sylvestre Do you still have the file somewhere? I suspect that this is just an encoding issue, because I can't reproduce it either. For reference, here's my /tmp/a:
In libc, this is detected by checking the length of a multibyte char is equal to a byte (locale-dependent): MB_CUR_MAX.
It appears uutils's wc uses utf8::BufReadDecoder thereby assuming always UTF-8.
Activity
cakebaker commentedon Jan 13, 2024
I can't reproduce this issue locally. GNU
wcreturns the same result as uutilswc:[-]Discrepancy in output length with special characters"[/-][+]Discrepancy in output length with special characters[/+]sylvestre commentedon Jan 13, 2024
try with a different local ?
like with LANG=C ?
cakebaker commentedon Jan 13, 2024
I tried
LC_ALL=C,LANG=CandLC_COLLATE=C, but no difference. And based on the doc of-LI would expect it to return2(and not1) because there are two characters.BenWiederhake commentedon Mar 2, 2024
@sylvestre Do you still have the file somewhere? I suspect that this is just an encoding issue, because I can't reproduce it either. For reference, here's my /tmp/a:
RenjiSann commentedon Feb 8, 2025
I can reproduce:
Also, a similar error is happening with
-m(number of characters).rwdj commentedon Feb 16, 2025
Confirming an issue with both
-Land-m:Although still a bug, it does appear encoding-related:
rwdj commentedon Feb 16, 2025
To be more specific, it's a matter of if bytes and multibyte chars are the same which depends on locale.
In libc, this is detected by checking the length of a multibyte char is equal to a byte (locale-dependent): MB_CUR_MAX.
It appears uutils's
wcusesutf8::BufReadDecoderthereby assuming always UTF-8.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