DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 4B2H33Jl1931107
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 4B2H33Jl1931107
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=XuGoi493
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52346385802C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1733158981;
	bh=Eyk5Bb/M3+bFNdOMQdsOwhcgx1Cj3R5nHuOIKSFJN3E=;
	h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=XuGoi4937VXXqJ5K5R6qyNjp7xl3xrzDYEBiOw50jCnZS3x3wdqnGWSkxWfO8rEJ0
	 hEUhZxIAAyhP10KLQ3WoXQhFJsPzdizkZHZaC+XpL/AioiCufVks/p7RAYwmAC2Ikh
	 4XUKFybtoj/PkO3zzdN/awsLvRsrfIiI3hTE0g+s=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF4AB3858C5F
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF4AB3858C5F
ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1733158908; cv=fail;
 b=xThElPaZ2GJF/v9janwMtuwx3TTn8IUPEZu9IiQDj7DrFoqelFaWlJPjSi++ggBnb1QnZa0hQ+VmJkyIWFSjLxQ4CdmRfq1JiF4f1mhThMwP6ly+TBCHPPPBDkzLqOIMa8pgAJc/xv1Rb13qPFF7gMXC09TmMnRRRwPOrQpYxOg=
ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key;
 t=1733158908; c=relaxed/simple;
 bh=kpksaOfOfzZJnmGIZGBHd2MAxgfEq7/VL6gg4MTGczY=;
 h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
 b=EhoKs3/DIWTSOON9pMP38chZuMeAOkdhLy7w88ChrQPYcNHKFCkGJExbTHEuyTofQl/6EYPsXu6BQI8XBn2x1WgqfD07r93df+WGRSg9X2PNthuanvSSgxOhN8WzDWZF5WZZ9SgPqb+u89rNyjz9EQAsVE0FxrOAWICPPsyEaQU=
ARC-Authentication-Results: i=2; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF4AB3858C5F
X-Sender-Id: dreamhost|x-authsender|gisburn@nrubsig.org
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1733158899; a=rsa-sha256;
 cv=none;
 b=CqGKTq5d5GkSgWNppOu1nsqKUdONI5OZjWyPdFSenMulZQpXOIwNLSeodm6Y2I91VgpipQ
 zbSiingOKaZlJ8ht1WqN9/Hw9+ZiMDwk2ipG3UzqIjWzZ9zUtwaavcHnNXjkT2XxfylkIm
 fAI0t95XHTZ57Dldmhsck7WF4WiJKsccVwvqla5VC4j34VgsugaqclZkj7iv/ngEyyOfTz
 MeKDE01XNlKw4XS5UQ9PRxi/iODhevHHuIDevntjAL4eMPkUjL+w5Jm18Smu2GV/rnZhK/
 zpU0iVmuJgtXCowpXppSE/hWeCnQYSJsozu2kaijq3FqBOBo6pOrqUha7K8Oyg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=mailchannels.net; s=arc-2022; t=1733158899;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references:dkim-signature;
 bh=8Vakc8/Awne+ShwZGcSOwTkyvU78ReSr5B6mddX/dTs=;
 b=5tXx9mKda2lUCVjVuwRLf6wlcJPW4DSYbNzNMAIYwJXm7qpDHFhDZXJKmkj4EpfKDuRmR5
 c/jlGHxOmgx7MVkM+P/KwrKjECtyS5q7l+5QnH8Yet5PFjlP38lwuZb2Goi0AYx+CBqpdO
 s8RzTIVM/yWpVOUk/FlMappftKyYtYKdgiSizMknHRxJGXJ7+3//vC55t8gYjDXd/0z6Gu
 L0r66S6+Pv/WpYLZcp/vlY0bROh+J2UdojvuNioeH9/oOKaVGiNlo7AGFX8dQYOgldX5pI
 40BNBk8WWoavJF6QhuRg0G1sy+BUezomCNxMGtXHFA49/+NAmWNikp0paHFS8Q==
ARC-Authentication-Results: i=1; rspamd-fc7fd4597-n7mrf;
 auth=pass smtp.auth=dreamhost smtp.mailfrom=roland.mainz@nrubsig.org
X-Sender-Id: dreamhost|x-authsender|gisburn@nrubsig.org
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|gisburn@nrubsig.org
X-MailChannels-Auth-Id: dreamhost
X-Quick-Squirrel: 5fb715f50bf11f6c_1733158899422_3773179498
X-MC-Loop-Signature: 1733158899422:2440419859
X-MC-Ingress-Time: 1733158899422
X-Gm-Message-State: AOJu0Yz8oUG5m5Mf7r3EHrCU1jSAyqzfMIQnwECEQ3HJie7Tgf5GHQmw
 ibHyeb/bkB4pE/fzbnyGCqSwQm1vTEFb6Ab1k2oi2QWRcldSza7uzlq5008caIHaPBwzBL7UiEC
 5yoUhlUt4ogWbWmRe4356OI5/TBg=
X-Google-Smtp-Source: AGHT+IHBh409K/412jVlG5a3PaldHemMUYD3wwLhrELRDLEpY9nt1uzYYfUI5Gcfcd6CKYoA9+JMeHhfwwc+4gfsIEk=
X-Received: by 2002:a5d:584a:0:b0:385:f470:c2e1 with SMTP id
 ffacd0b85a97d-385f470c6eemr3081132f8f.2.1733158897477; Mon, 02 Dec 2024
 09:01:37 -0800 (PST)
MIME-Version: 1.0
References: <CAKAoaQ=wrTyHTVxryHafHfBbkpF0e4+Tkrm8V9VvVH+LmLDKUw@mail.gmail.com>
 <2bcf040e-0fca-4033-b23b-15bb0583bc5b@SystematicSW.ab.ca>
In-Reply-To: <2bcf040e-0fca-4033-b23b-15bb0583bc5b@SystematicSW.ab.ca>
Date: Mon, 2 Dec 2024 18:01:11 +0100
X-Gmail-Original-Message-ID: <CAKAoaQ=GEN9nCRPXsdNx7wA+4drkCC6JDkmruNxB_9N=4rmULQ@mail.gmail.com>
Message-ID: <CAKAoaQ=GEN9nCRPXsdNx7wA+4drkCC6JDkmruNxB_9N=4rmULQ@mail.gmail.com>
Subject: =?UTF-8?B?UmU6IFByb2JsZW0gd2l0aCAn4oKsJyAoRVVSTykgc3ltYm9sIGluIChVKUNSVCB8cHJpbg==?=
 =?UTF-8?B?dGYoIiVTIiwgLi4uKTt8IC4uLg==?=
To: cygwin@cygwin.com
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
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: Roland Mainz via Cygwin <cygwin@cygwin.com>
Reply-To: Roland Mainz <roland.mainz@nrubsig.org>
Content-Type: text/plain; charset="utf-8"
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 4B2H33Jl1931107

On Wed, Nov 27, 2024 at 1:49 AM Brian Inglis via Cygwin
<cygwin@cygwin.com> wrote:
>
> On 2024-11-26 17:08, Roland Mainz via Cygwin wrote:
> > Cygwin 3.5.4/Win10/64bit, the following program prints a '?' where I
> > would expect a '€' (EURO) symbol:
> > ---- snip ----
> > printf '#include <stdio.h>\n#include <wchar.h>\n#include
> > <io.h>\n#include <fcntl.h>\n#include <locale.h>\nint main(int ac, char
> > *av[]) { setlocale(LC_ALL, ""); printf("%%S\\n", L"hello € world");
> > return 0; }\n' >x.c && clang -target x86_64-pc-windows-gnu -Wall x.c
> > -o x.exe && ./x.exe
> > hello ? world
> > ---- snip ----
> >
> > My hope was that - because Win32 uses UTF-16 for |wchar_t| - that the
> > EURO symbol can be displayed on any locale/code page which supports
> > the EURO symbol, but somehow I always get a '?'.
> >
> > Does anyone know what I am doing wrong ?
>
> $ grep -aw EURO ~/src/charsets/unicode-symbols.txt
> ₠  U+20A0   EURO-CURRENCY SIGN
> €  U+20AC   EURO SIGN
> 💶 U+1F4B6  BANKNOTE WITH EURO SIGN
>
> What is your terminal locale and charset?

LC_ALL=en_US.UTF-8.

But it turns out my issue is a bit UCRT-specific:
It seems UCRT |printf()| is not able to print wide-char values in all
locales/codepages - instead I have to use |wprintf()| and
|_setmode(_fileno(stdout), _O_WTEXT);|.
Unfortunate side-effect is that putting stdout/stderr in wide-char
mode makes any attempt to do a single-char |printf()| fail with an
assert.

Cygwin's native stdio doesn't have that limitation.

But now I am a bit cursing because of this little issue from
https://learn.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=msvc-170
---- snip ----
... For historical reasons, the wprintf functions use c and s to refer
to wchar_t characters, and C and S specify narrow characters. ...
---- snip ----
... but it turns out that at least in UCRT you can |#define
_CRT_STDIO_ISO_WIDE_SPECIFIERS 1| to fix this.

Question is in which Windows or Visual Studio version added this feature...

----

Bye,
Roland
-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)

-- 
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

