C++ Logo


Advanced search

Re: [SG16] Questions for LEWG for P2093R4: Formatted output

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 21 Mar 2021 09:47:23 -0700
On Sunday, 21 March 2021 06:40:44 PDT Victor Zverovich wrote:
> > Strictly speaking, that's implementation-defined. You can reopen stdout
> > with the ",css=<codec>" flag to fopen to cause transcoding to happen.
> Interesting, would it be standard-compliant? In any case, MSVC doesn't do it
> according to the test.

Yes, it's standards-compliant to transcode. The ",ccs" argument is not in the
C standard (see https://cigix.me/c17# nor POSIX[1] but informing how
you want the C library to transcode does not prevent it from choosing to do so
on its own. The existence of wprintf() is sufficient reason for that ability
to exist.

MS documentation[2] is that the ",ccs" argument can be used to specify one of
the Unicode encodings, but not the ACP (I guess that's just the default). The
glibc documentation says that any encoding understood by iconv is valid there.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html
[2] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2021-03-21 11:47:31