This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wcwidth and terminals [Re: Mg3a - a version of Mg2a developed on Cygwin]


On Feb 25 09:05, Thomas Wolff wrote:
> Am 24.02.2011 09:56, schrieb Corinna Vinschen:
> >When on Cygwin, you might better use Cygwin's(*) wcwidth function.  It's
> >based on the same code from Markus Kuhn, but it interacts with the
> >setlocale function to make sure that the width returned for the CJK
> >ambiguous width characters makes sense in the given locale.  Plus, it
> >supports a Cygwin-specific locale modifier '@cjknarrow' which allows the
> >user to modify this behaviour.  When using your own wcwidth, you're
> >giving up on this feature.
> On the other hand, not specific for cygwin, the wcwidth/wcswidht
> functions are in general based on installed locale data.
> But you can never know whether the terminal you are running in
> actually uses those data.
> On a Linux system, you may encounter a wide range of different
> environments, for example:
> rxvt based on system locale which is often based on an outdated
> locale data installation (e.g. Unicode 3)
> xterm with a hard-coded wcwidth
> mlterm with some tweaks
> remote operation (rlogin/ssh to/from other system) with inconsistent
> locale data base
> ...
> 
> For that reason, my editor mined implements an auto-detection of
> actual terminal width data (checking Unicode version and a number of
> terminal-specific odds).
> 
> For cygwin, it might be useful (although not standard) for wcwidth
> to consider whether it's running in a cygwin console or a terminal,
> so e.g. wcwidth (0x8080) should return 2 in mintty but 1 in a cygwin
> console.

Hmm, I don't think that's the right thing to do.  How's the OS version
of wcwidht supposed to know what the wcwidth function is used for?
After all, the application does *not* specify that it calls wcwidth
to get the size of a character for a specifc purpose.  How's the function
to know that the character is supposed to be printed to the current tty?
What if the application has open handles to more than one tty?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]