delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/02/25/03:05:38

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,TW_RX,TW_WC,TW_WW
X-Spam-Check-By: sourceware.org
Message-ID: <4D6762B5.3000204@towo.net>
Date: Fri, 25 Feb 2011 09:05:09 +0100
From: Thomas Wolff <towo AT towo DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: wcwidth and terminals [Re: Mg3a - a version of Mg2a developed on Cygwin]
References: <35i9m6pt07r66fib882etg5tgirkr413co AT 4ax DOT com> <0105D5C1E0353146B1B222348B0411A209DAA0FF98 AT NIHMLBX02 DOT nih DOT gov> <fklam6ptp2uu7o029pkng8e4vc953fnfme AT 4ax DOT com> <ijmam6h3u1vq8nepvdlfo3hcb5feoeihav AT 4ax DOT com> <20110224085617 DOT GM9392 AT calimero DOT vinschen DOT de>
In-Reply-To: <20110224085617.GM9392@calimero.vinschen.de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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.

Erik Blake wrote:
> And if you don't mind [L]GPL licensing, gnulib provides a source code
> replacement that guarantees wide character support on all modern porting
> platforms (particularly useful for mingw, which is sorely lacking on
> this front); and is currently working on introducing a wwchar_t type
> that is guaranteed to be UTF-32 even on cygwin (this is how coreutils
> gets wide character support for things like wc).  Portions of that
> gnulib code are incorporated into libunistring.  But from the sounds of
> your program's license, I'm not sure you can take advantage of gnulib or
> libunistring.
Maybe I should check whether my auto-detection code could be contributed 
to that project...

Thomas

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019