Ienup Sung wrote on 2001-01-24 22:23 UTC:
> The wcwidth(3C) of POSIX requires to return, in general sense, four
> distingtive values, 0, 1, 2, and -1.

There is no wcwidth in POSIX. It is found in X/Open SUS

  http://www.opengroup.org/onlinepubs/007908799/xsh/wcwidth.html

and it is was mentioned in an informal appendix of ISO C 90 Amd. 1 but
is not part of the C standard (was in a draft, but removed from the
final version).

> Hence we need only two bits per
> each character. Which means for a plane, you will need 2 x 65536 bits
> and that is 16KB for a plane if you want to have a faster algorithm for
> width calculation and thus want to have the width values available for
> all Unicode characters in the plane. This will require that the kernel will
> eventually need to have 16KB x 17 planes = 272KB to represent all possible
> Unicode characters. As a starter, though, we will only need 16KB x 3 = 48KB
> of memory space if we count only BMP, SMP, and SIP planes.
> 
> Further compaction of memory space is possible if necessary of course.

A) A classic Unix kernel doesn't need wcwidth at all, because the kernel
is ignorant of absolute kernel positions and only uses LF and BS for
cursor control.

B) My reference implementation of wcwidth on

  http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c

is 2.5 kilobytes long (compiled code plus data tables covering all UCS
planes), and in this form more then sufficiently efficient for editors.

Adding wcwidth to the kernel would be rather trivial, but if we have to
add it, then only to the terminal emulator, not to the tty editor.

Markus

-- 
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>

-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/lists/

Reply via email to