bug-gnulib
[Top][All Lists]
Advanced

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

Re: Variant wcwidth results on Solaris


From: Bruno Haible
Subject: Re: Variant wcwidth results on Solaris
Date: Sat, 30 Mar 2019 02:30:52 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

Hi Gavin,

> I wondered if there has been any change since this report:
> 
> https://lists.gnu.org/archive/html/bug-gnulib/2008-08/msg00209.html
> 
> The issue is that on Solaris 10 and Solaris 11, wcwidth returns 2 
> instead of 1 for some characters, for example, opening double quote “.
>
> Some of these characters are listed as "ambiguous" under 
> http://unicode.org/reports/tr11-2/, but having different results on 
> different systems makes a test suite almost useless on at least one of 
> the systems.

This has not really changed. Different systems have different terminal
emulators, and accordingly also different wcwidth functions. Therefore
there is no single, unique, portable definition of wcwidth. Except for
the issues documented [1], gnulib does not override the system function.

> Would it be possible for gnulib to override the system wcwidth if it has
> unusual return values?

When you use a gnulib module that overrides a system function, you
can influence its behaviour by setting the cache variable before gl_INIT.
In this case, if you set
  gl_cv_func_wcwidth_works=no
you will get the gnulib override on all platforms.

Or you can modify the test program locally, for your package. [2]

> wcwidth is used by the texi2any program in Texinfo to output to 
> monospaced plain text for use in a terminal emulator.  It is used for 
> wrapping lines.

Ah, but wcwidth is a poor algorithm for line-breaking. The modern
algorithms are specified in Unicode, and you have an implementation
of the essential part of this algorithm in gnulib and in libunistring.

In gnulib it is in the modules
  unilbrk/ulc-width-linebreaks
  unilbrk/u8-width-linebreaks
  unilbrk/u16-width-linebreaks
  unilbrk/u32-width-linebreaks
Pick the one that fits your needs.

Another approach is to not include the code from gnulib, but instead
rely on a preinstalled GNU libunistring. For this, use the gnulib
module 'libunistring'.

A third approach is to use GNU libunistring when it is installed,
and use the included source code when it is not installed. To this
effect, use the specific unilbrk/* module(s) and the module
'libunistring-optional'.

This way, you will get (nearly) the same results across platforms.
I say "nearly", because Unicode changes over time, and GNU libunistring's
data tables change a bit as well. So, occasionally (rarely), you may
get different results. Occasionally, you may have to update your testsuite's
expected results.

Bruno

[1] https://www.gnu.org/software/gnulib/manual/html_node/wcwidth.html
[2] https://www.gnu.org/software/gnulib/manual/html_node/Extending-Gnulib.html




reply via email to

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