bug-texinfo
[Top][All Lists]
Advanced

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

Re: texinfo-6.8.90 pretest


From: Eli Zaretskii
Subject: Re: texinfo-6.8.90 pretest
Date: Sat, 22 Oct 2022 21:39:14 +0300

> From: Gavin Smith <gavinsmith0123@gmail.com>
> Date: Sat, 22 Oct 2022 18:16:35 +0100
> Cc: Patrice Dumas <pertusus@free.fr>, bug-texinfo@gnu.org
> 
> > Not for Windows, because Windows lacks the nl_langinfo function, for
> > which this module is a think wrapper on Unix.
> > 
> > AFAIU, on Windows this module is available only starting from v5.28.
> 
> Can we use LC_CTYPE, like:
> 
> diff --git a/tp/texi2any.pl b/tp/texi2any.pl
> index d6061bd8f0..8864ebeedc 100755
> --- a/tp/texi2any.pl
> +++ b/tp/texi2any.pl
> @@ -26,7 +26,9 @@ require 5.00405;
>  use strict;
>  
>  # to determine the locale encoding
> -use I18N::Langinfo qw(langinfo CODESET);
> +#use I18N::Langinfo qw(langinfo CODESET);
> +use POSIX qw(setlocale LC_ALL LC_CTYPE);
> +
>  # to decode command line arguments
>  use Encode qw(decode encode find_encoding);
>  # for file names portability
> @@ -297,7 +299,12 @@ if ($texinfo_dtd_version eq '@' . 
> 'TEXINFO_DTD_VERSION@') {
>  # the encoding used to decode command line arguments, and also for
>  # file names encoding, perl is expecting sequences of bytes, not unicode
>  # code points.
> -my $locale_encoding = langinfo(CODESET);
> +# my $locale_encoding = langinfo(CODESET);
> +my $locale_encoding = POSIX::setlocale(LC_CTYPE);
> +
> +# extract MODIFIER from LANGUAGE[_TERRITORY[.CODESET]][@MODIFIER]
> +$locale_encoding =~ s/^[^.]*.//;
> +$locale_encoding =~ s/@.*$//;
>  $locale_encoding = undef if ($locale_encoding eq '');
>  
>  # Used in case it is not hardcoded in configure and for standalone perl 
> module
> 
> If this works then we could switch to it and not use I18N::Langinfo at
> all.

This works here, and produces the codepage number.  But (due to the
Windows peculiarities which I won't go into), it isn't the same
codepage number as the "current system ANSI codepage", which is
retrieved by the GetACP call I showed in my previous message.  So from
my POV, on Windows it is better to use the GetACP call via Win32::API
module, as that produces a codepage that is more accurate in some
cases.

In any case, both methods produce just a number, not an encoding
identifier.  We will need to prepend something to it, like "CP" maybe,
depending on how the codeset is used by texi2any.



reply via email to

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