[Toybox] wc -L

Rob Landley rob at landley.net
Mon Feb 5 09:17:00 PST 2024


Who was it who asked for wc -L again? Because here's what the debian version is
doing:

$ echo a | wc -L
1
$ echo -n a | wc -L
1
$ echo -e '\ta' | wc -L
9
$ echo -e '\t\b' | wc -L
8
$ echo -e '\t\b\bx' | wc -L
9
$ echo -e '\t\b\b\b' | wc -L
8
$ echo -e 'abc\td' | wc -L
9
$ echo -e 'abc\bd'
abd
$ echo -e 'abc\bd' | wc -L
4
$ echo -e '\x01' | wc -L
0
$ echo -e 'w\xcc\x88'
ẅ
$ echo -e 'w\xcc\x88' | wc -L
1
$ wc -m tests/files/utf8/japan.txt
25 tests/files/utf8/japan.txt
$ wc -L tests/files/utf8/japan.txt
50 tests/files/utf8/japan.txt
$ wc -c tests/files/utf8/japan.txt
75 tests/files/utf8/japan.txt

So wc -L isn't QUITE the fold.c logic, because it treats backspace like any
other low ascii character (I.E. width zero). But otherwise it does tabs and
measures unicode wide and combining characters.

Alas, my first naive implementation... didn't do all that yet.

Rob


More information about the Toybox mailing list