X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Fri, 25 Feb 2011 12:05:30 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT 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 AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <35i9m6pt07r66fib882etg5tgirkr413co AT 4ax DOT com> <0105D5C1E0353146B1B222348B0411A209DAA0FF98 AT NIHMLBX02 DOT nih DOT gov> <20110224085617 DOT GM9392 AT calimero DOT vinschen DOT de> <4D6762B5 DOT 3000204 AT towo DOT 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 AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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