bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CDK selection widget and aligning text


From: Mike Gran
Subject: Re: CDK selection widget and aligning text
Date: Mon, 23 Mar 2009 08:29:02 -0700 (PDT)

> From: Tim Allen <address@hidden>
> On Sat, Mar 21, 2009 at 04:41:18AM -0700, TheLonelyStar wrote:
> > The trouble is, I use UTF-8 characters (umlaute in example). And how to not
> > know how to count the displayed string length ...
> 
...
> I believe that in an ideal world, an algorithm for measuring the
> on-screen width of a Unicode string would be something like this:

While everything Tim said is correct, you can usually get the correct
answer by using the function mk_wcwidth() that Marcus Kuhn wrote.  That function
gives you with usual width of each character as 1, or 2 cells, or 0 for 
combining
characters like umlaut.

You can find it here

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

-Mike Gran




reply via email to

[Prev in Thread] Current Thread [Next in Thread]