[Toybox] [PATCH] vi.c improved utf-8 support

Jarno Mäkipää jmakip87 at gmail.com
Thu Mar 28 00:10:57 PDT 2019


Now calculates utf-8 rune width properly before trying to print on screen.
works with test1.txt and test2.txt on tests/files/utf8 folder with
0x0300-0x036F combining chars

Uses mbtowc and wcwidth to calculate width of rune. These both should be
implemented on c runtime that conforms POSIX-1.2001. Different c
runtimes might have different level of support to combining char
ranges etc...

I think there is no standard way to calculate utf-8 rune width without
converting it first to widechar. And i think conversion to widechar just
to calculate width is silly, since all write calls can be done with utf8
directly (on utf8 locales ofc), but in order to calculate them yourself
without pointless conversion, one would need to write variable byte lookup
array for binary searching weird ranges and make sure it works with
big-endian
systems too...

By the way running ./watch ./cat tests/files/utf8/japan.txt does not print
the
text for some reason, but other test data does... I was checking how
well original crunch_str works and noticed it.

-Jarno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190328/aecf7a1e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vi.c-improved-utf-8-support.patch
Type: text/x-patch
Size: 9724 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190328/aecf7a1e/attachment.bin>


More information about the Toybox mailing list