public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@Shaw.ca>
To: cygwin@cygwin.com
Subject: Re: newlocale: Linux incompatibility
Date: Sat, 25 Mar 2023 13:03:49 -0600	[thread overview]
Message-ID: <8f2b7a49-2878-8481-233c-146fdb9a0e69@Shaw.ca> (raw)
In-Reply-To: <ZB7fsuNoUY9miWr+@calimero.vinschen.de>

On 2023-03-25 05:49, Corinna Vinschen via Cygwin wrote:
> On Mar 24 16:49, Brian Inglis via Cygwin wrote:
>> On 2023-03-24 06:18, Corinna Vinschen via Cygwin wrote:
>>>> First, it's a bug in the Emacs testsuite.  The test simply assumes that
>>>> there's no en_DE locale on any system, but that's just not true.
>>>> Windows support the RFC 5646 locale "en-DE", which is called "English
>>>> (Germany)" in the "Region" settings.
>>>> You can also check with `locale -av | less' and search for en_DE.
>>>> For the reminder of this mail, I assume you're talking about Cygwin 3.5.
>>>> I won't fix this for 3.4 anymore, given how much locale handling has
>>>> changed for 3.5.
>>>> The second bug is that Cygwin blindly trusts the Windows function
>>>> ResolveLocaleName().  That function blatantly converts even vaguely
>>>> similar locales into something it supports.  E.g., it converts "en-XY"
>>>> to "en-US".  I. .e., even if you use "en_XY.utf8" as locale, the above
>>>> testcase will wrongly succeed.  So I have to rethink how I resolve POSIX
>>>> locales to Windows locales.

>> Does Windows even consider https://www.rfc-editor.org/rfc/rfc4647 "Matching
>> of Language Tags", part of https://www.rfc-editor.org/info/bcp47 "Language
>> Tags", and if POSIX only matches exactly, will LANGUAGE be able to be used
>> for fallback?

> I never heard about an environment variable called LANGUAGE.  This is
> about LANG/LC_ALL/LC_whatever, so POSIX syntax is required...

Used by gettext:

https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html

also LINGUAS FYI controlling, documentating, or limiting translations:

https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html
https://www.gnu.org/software/gettext/manual/html_node/Installers.html

as POSIX punts a lot of locale handling into the (hand waving) implementation 
defined bucket, where this is the primary implementation.

>> I currently define LANGUAGE=en_CA:en_GB:en in case en-CA is unsupported by
>> anything.
>> [I use my own en-CA locale not the glibc default created by https://rap.dk/.]
>> Will "-" be supported like "_" as a separator in values?

> In Cygwin?  No.  The POSIX syntax is required, it's converted into
> a matching Windows RFC 5646 locale internally.

>>>> And the third bug is that Cygwin fails to set errno if it doesn't
>>>> support a locale, but that's a minor inconvenience in comparison.
>>>> Thanks for the report, I totally missed the above problem with
>>>> ResolveLocaleName.

>>> I pushed a couple of patches which hopefully clean up the code.  It's
>>> really frustrating how these Windows locale functions work.  Or, rather,
>>> not work.  I mean, come on...
>>> - ResolveLocaleName() resolves "ff-BF" to "ff-Latn-SN", not to
>>>     "ff-Adlm-BF" or "ff-Latn-BF", even though both exist.
>>> - There's a locale called "sd-Arab-PK" and a locale "sd-Deva-IN".  If
>>>     you ask for the script used in "sd-IN", the result is "Arab", not
>>>     "Deva".
>>> I had to create a replacement function for ResolveLocaleName which
>>> doesn't return totally screwy and unexpected results, and special case
>>> two more locales in /proc/locales output so the output makes sense.

>> Aha - a nice new 3.5.0 feature - as well as /proc/codesets - is that
>> charsets e.g. ISO-10646, etc. rather than encodings e.g. UTF-8, etc.!

> It's a list of what you can use as codeset in $LANG and friends as in
>    LC_CTYPE=lang_TERRITORY.codeset@modifier

You are using codeset to mean encoding, whereas in Unicode and W3 it usually 
means coded character set/charset; it can also mean charmap; see iconv(1):

	https://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html

Further confused by codeset definition:

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_99

linking to:

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap06.html#tag_06_02

which says POSIX "provides no means of defining a wide-character codeset" 
implying encodings such as UCS-2/UTF-16 and UCS-4/UTF-32 can not be specified, 
requiring a non-POSIX approach to conversion.

Also IBM uses codeset to distinguish between EBCDIC and ASCII encodings.

Adding to the confusion ISO uses codeset to refer generically to each set of 
codes supported by each part of ISO-639-1/2/3/5, ISO-3166-1/2/3, and ISO-15924, 
as well as ISO-8859-1...16.

I get no hits from RFCs.

To avoid ambiguity and reduce possible confusion, it may be better to name this 
charmaps as used in locale(1), and produced by locale -m with the same apparent 
content?
It looks like /proc/locales contains the same content as produced by locale -a?

JM2c ;^>

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

  reply	other threads:[~2023-03-25 19:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 19:48 Ken Brown
2023-03-23 20:09 ` Thomas Wolff
2023-03-23 21:14 ` Corinna Vinschen
2023-03-24 12:18   ` Corinna Vinschen
2023-03-24 13:57     ` Ken Brown
2023-03-24 14:44       ` Corinna Vinschen
2023-03-24 22:49     ` Brian Inglis
2023-03-25 11:49       ` Corinna Vinschen
2023-03-25 19:03         ` Brian Inglis [this message]
2023-03-25 21:19           ` Corinna Vinschen
2023-03-25 21:26           ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f2b7a49-2878-8481-233c-146fdb9a0e69@Shaw.ca \
    --to=brian.inglis@shaw.ca \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).