From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26019 invoked by alias); 25 Feb 2011 11:06:01 -0000 Received: (qmail 25979 invoked by uid 22791); 25 Feb 2011 11:05:40 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Fri, 25 Feb 2011 11:05:33 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 7197D2C02F7; Fri, 25 Feb 2011 12:05:30 +0100 (CET) Date: Fri, 25 Feb 2011 11:06:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: wcwidth and terminals [Re: Mg3a - a version of Mg2a developed on Cygwin] Message-ID: <20110225110530.GX9392@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <35i9m6pt07r66fib882etg5tgirkr413co@4ax.com> <0105D5C1E0353146B1B222348B0411A209DAA0FF98@NIHMLBX02.nih.gov> <20110224085617.GM9392@calimero.vinschen.de> <4D6762B5.3000204@towo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4D6762B5.3000204@towo.net> User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-02/txt/msg00535.txt.bz2 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