[Toybox] [PATCH] cut: re-enable crunch_str on cut -C

Jarno Mäkipää jmakip87 at gmail.com
Thu Oct 24 23:14:10 PDT 2019


ping

While its not necessary to apply this patch I was hoping to rise some
conversation. My point is that crunch_str() works correctly. It pushes
0 width combining chars to stdout even after colums==width. And reason
it renders wrong is terminal clients fault. While there is no
standard, the xterm terminal client that is closest thing to reference
implementation works correctly. And if user just pipe outputs to file
or program that can actually handle them, it would be right thing to
not clip them in wrong place.

cut -C is toybox extension so it does not matter how it works, but if
it would work correctly it could be used to test other commands maybe?


br
Jarno


On Fri, Oct 18, 2019 at 9:23 PM Jarno Mäkipää <jmakip87 at gmail.com> wrote:
>
> Since there has been lots of topic about rendering combining
> characters I leave this commit here for discussion. crunch_str
> currently prints combining characters right. you are free to prove me
> wrong
>
> Combining characters follow the character which they modify.
> https://www.cl.cam.ac.uk/~mgk25/unicode.html#comb
>
> xterm renders cut test1.txt -C -1 now correctly, other terminal
> emulators have different results, but anyway leaving glyph incomplete
> would sacrifice that you wont be later able view it inside browser for
> example either.
> My previous message to board about vi combining chars had some utf-8
> with combining characters in it. and my ipad:s browser rendered it
> correctly, but this desktop browser did not...
>
> I dont think its good idea to leave glyph imcomplete just because some
> terminal emulators misbehave and render combining chars sometimes
> after the main glyph. Leaving glyph incomplete without combining
> characters could leave word unreadable for user that is actually
> reading his own language with his own terminal or browser that
> actually works.
>
> I will also attach 2 screenshots into mailinglist where without_crunch
> is the old implementation
> cut_with_crunch.png
> cut_without_crunch.png
>
> regards
> -Jarno
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cut_with_crunch.png
Type: image/png
Size: 3404 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191025/f56a8c56/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-cut-re-enable-crunch_str-on-cut-C.patch
Type: application/x-patch
Size: 2784 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191025/f56a8c56/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cut_without_crunch.png
Type: image/png
Size: 4034 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191025/f56a8c56/attachment-0007.png>


More information about the Toybox mailing list