Grapheme clusters and east asian width

Eli Zaretskii eliz at gnu.org
Thu Sep 17 09:47:53 CDT 2015


> Date: Thu, 17 Sep 2015 13:27:31 +0100
> From: Richard Wordingham <richard.wordingham at ntlworld.com>
> 
> The best estimator is probably the POSIX function wcswidth().

Only on glibc-based systems, I'm quite sure.

> The
> terminal emulator might actually use that function to do its layout.
> Some do. If you need accuracy, you may have to resort to asking the
> terminal where the cursor is.  Of course the latter might not work
> if only the general concept of a terminal (perhaps, better, teletype)
> is being emulated.  I wouldn't expect either to work for an application
> being run from the emacs shell program, which works with 'proportional'
> fonts, though one might get a pleasant surprise. (For example, emacs
> *might* *convert* the cursor position to nominal cell widths.)

When Emacs displays on a text terminal, it's up to the terminal to
handle the font; Emacs speaks to the terminal in character cell units.
When Emacs displays on a graphics terminal, it works in pixels, so
cursor position in character units is not useful.

In any case, where do you think Emacs takes its idea of the width of
every character?  What other database could it use, that can be relied
upon on any of the modern OSes, except the UCD?


More information about the Unicode mailing list