bug-texinfo
[Top][All Lists]
Advanced

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

Re: Texinfo 7.0.93 pretest available


From: Bruno Haible
Subject: Re: Texinfo 7.0.93 pretest available
Date: Mon, 09 Oct 2023 23:32:49 +0200

Gavin Smith wrote:
> It is supposed to attempt to force the locale to a UTF-8 locale.  You
> can see the code in xspara_init that attempts to change the locale.  There
> is also a comment before xspara_add_text:
> 
>   "This function relies on there being a UTF-8 locale in LC_CTYPE for
>   mbrtowc to work correctly."

That's an inherently unportable thing. You can't just force an UTF-8
locale if the system does not have it.

> For MS-Windows there is the w32_setlocale function that may use something
> different:
> 
>   /* Switch to the Windows U.S. English locale with its default
>      codeset.  We will handle the non-ASCII text ourselves, so the
>      codeset is unimportant, and Windows doesn't support UTF-8 as the
>      codeset anyway.  */
>   return setlocale (category, "ENU");
> 
> mbrtowc has its own override which handle UTF-8.

On native Windows, with the (lots of!) Gnulib overrides, with the MSVC compiler
the locale French_France.65001 is a UTF-8 locale. But with mingw this does
not work; probably something in mingw's setlocale() works differently than
in MSVC's setlocale().

In summary: On mingw there is no UTF-8 locale, and you cannot force it.

The only portable way out is to use iconv() instead of setlocale(), mbrtowc(),
etc. This is how e.g. gettext's PO parser does it:
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/src/po-lex.c;h=22d08849206b812b18ace9de7629bb95a9d71c3c;hb=c9af3e4eeccc178a0833754e3d8c7083591e75ba
lines 127..595. You will also find a function mb_width in there.

Note that switching from locales to hand-written encoding support is a
major change; I wouldn't recommend to do it before Texinfo 7.1.

Bruno






reply via email to

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