From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by sourceware.org (Postfix) with ESMTPS id 05FB13858C27 for ; Mon, 13 Mar 2023 10:49:41 +0000 (GMT) Authentication-Results: sourceware.org; dmarc=permerror header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MyJx6-1qTKdb1nfo-00yke6; Mon, 13 Mar 2023 11:49:39 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id DEF67A80C87; Mon, 13 Mar 2023 11:49:38 +0100 (CET) Date: Mon, 13 Mar 2023 11:49:38 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Cc: Yeo Kai Wei Subject: Re: [ERROR] Locale Monetary Symbol Prints Wrongly on Windows : Cygwin Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, Yeo Kai Wei References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 List-Id: 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