X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A62453858407
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1678704619;
	bh=/QgVLxTGtdRjGiCmFsHyEIcxvCIFb448QQWJxIx18dc=;
	h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=tP+Sp2Wu6ox143R5PtIDtx83F89RfOJlUTSva/lMxEohXWGeOPqNsGZJhGx1O9AE7
	 FWilf/btjH3702OtOyEtksTVpgF3W9aXBGm1Z9XAognJ2p99UGff7anazEVMjphBtj
	 L5ueTv55vSfGbZhQPNXw65sn2LkdHTuJ8t03sKmQ=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
Date: Mon, 13 Mar 2023 11:49:38 +0100
To: cygwin@cygwin.com
Subject: Re: [ERROR] Locale Monetary Symbol Prints Wrongly on Windows : Cygwin
Message-ID: <ZA7/wmI5MGFmAPcg@calimero.vinschen.de>
Mail-Followup-To: cygwin@cygwin.com, Yeo Kai Wei <yeokaiwei@hotmail.com>
References: <PH0PR05MB9918E3261DF25870A4834D3AA4B99@PH0PR05MB9918.namprd05.prod.outlook.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <PH0PR05MB9918E3261DF25870A4834D3AA4B99@PH0PR05MB9918.namprd05.prod.outlook.com>
X-Provags-ID: V03:K1:4XFkq8kQ4QJY+F0dyjSZnAb5aj/uvD9gKQb8pgR+lEht57sqzmu
 e+KpXrm4bZWPbLRQBchg2JTWsfe9iBdVQiEnEZO6gdFDHoUeCKFu3e/VEHU7WzaHzto4vsD
 66SphPTLXqbwKaHTJhtRlDrVh4upOgbqE2FVknSbICaVto1/INjJOGxNedp9dDgYx+TNV2U
 z46HuDj0G0ZtTwmlxJ+kg==
UI-OutboundReport: notjunk:1;M01:P0:JN873GJAjWo=;ZLTnUstFMVMS4/D2+C+eKdw8+Xy
 X98qbtwNx6K0FOdMGyz/l+ePxTwzcaPte1qI2c103z2FZGXVJ6Io6A5NVRDu5eV7JZfgleMGR
 CsWK2iPgPIsCwvXjBlSJ0Z54Eelwma4mXPVpnjlo4Ry/vQx7I6UMmzDRWmoTD72/W7IAftyUl
 hT53hDY5mkKx5L9iGZ6Wf6GdVyu6QF3FO0EqxwlPFdg5xKVXlZV8UY1P/OS8yjmDuMgkpWPdI
 28abRwF4NnPN1gvmPKbbf8/+ti5VY+jI8/Z4BfpCE2qEMHNr/r46D8FRAoB4U2IiJdIyArthl
 W2qgczq51pnuwIRUlTiPYARApZt4yKlnAGvlh08/uX6eKYyQhQ064LR0e1dNIxMPMlqttNgHz
 wvo5R8Nr6Fz8JCPucbpEOdrbEOskmlOYyWIPRcfWa71CDS0vC2CrzsbxDceKmEY65CLfZ5fHC
 h4KC0D5jX8LGtyREPvZGOvKFZDQw4bQ8bL9WlRAM0bZkPxKGfNi8zmmuti6f5QeSqVw2SXf5i
 fuufddV7dlqc50yMtPua2SHqRaeQBNzr2qxTKqfog3Dh1TMmZR0BNEmnsaXlQpZNmQP1P+6fG
 ygVZrkrVi5eTgBBzpBPrwmg7ZhkM/6Sw9Lk4xsQEpRM9MIteG8Em2tTBB2x/O+cGmtp1QAJfN
 b6ZjQAMM21hr3SL8qdcevHbJQwT/KhHfCh6mIxsaCg==
X-Spam-Status: No, score=-95.3 required=5.0 tests=BAYES_00, BODY_8BITS,
 GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_STATUS, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE,
 RCVD_IN_MSPIKE_H2, SPF_FAIL, SPF_HELO_NONE,
 TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>,
        Yeo Kai Wei <yeokaiwei@hotmail.com>
Content-Type: text/plain; charset="utf-8"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 32DAoji3004961

On Mar 13 08:40, Yeo Kai Wei via Cygwin wrote:
> Hi All,
> 
> May I ask if there's a bug with Cygwin and Windows currency?

The en_ZM locale isn't yet supported by Cygwin.  This will change with
Cygwin 3.5.0.  You can install the latest Cygwin test release
3.5.0-0.231.g93f70d7849b8 and retry.  You'll get the correct output:

Region: en_AU.utf-8 Currency symbol: $ International currency symbol: AUD
Region: en_CA.utf-8 Currency symbol: $ International currency symbol: CAD
Region: en_GB.utf-8 Currency symbol: £ International currency symbol: GBP
Region: en_US.utf-8 Currency symbol: $ International currency symbol: USD
Region: en_NZ.utf-8 Currency symbol: $ International currency symbol: NZD
Region: en_ZM.utf-8 Currency symbol: K International currency symbol: ZMW

Btw., you don't even need a test application, just call

  $ LC_MONETARY="en_ZM.utf-8" locale -ck LC_MONETARY

> The correct answer should be "Region: en_ZM.utf-8 Currency symbol: K
> International currency symbol: ZMK"
> 
> Supposedly, the code works on Linux.
> 
> Is this an issue with Windows?

We're fetching most locale information from Windows, this includes the
LC_MONETARY information.  However, the locale support up to Cygwin 3.4.x
is restricted by an issue in Windows:

Originally, locales were handled in Windows by using so called locale
identifiers, LCID, 2 byte numbers.  These LCIDs are used by Cygwin
internally.

In the meantime, Windows switched from LCIDs to locale string
identifiers following RFC 4646 resp. RFC 5646. Now, the problem is this:

Cygwin didn't yet follow suite, still using LCIDs internally, but
Windows introduced locales for which no LCID has ever been assigned.
Asking for the LCID for "en-ZW" returns 0.

For Cygwin 3.5.0, I converted Cygwin to use RFC 5646 locale strings
internally, too, so the next major version of Cygwin will be able to
support all locales Windows supports.

>     while (regions[i])
>     {
>         setlocale(LC_MONETARY, regions[i]);

You're not checking for errors here.  If the locale isn't supported,
setlocale should return NULL...

>         const struct lconv* loc = localeconv();

...and the locale information stays unchanged.  As such, if en_ZM isn't
supported, this call will still fetch the information of the en_NZ.utf-8
locale.


HTH,
Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

