C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] UTF-8 support status

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 02 Jul 2026 22:19:49 -0700
On Thursday, 2 July 2026 21:45:56 Pacific Daylight Time Thiago Macieira via
SG16 wrote:
> On Thursday, 2 July 2026 21:10:23 Pacific Daylight Time Victor Zverovich
wrote:
> > This only applies to legacy Windows APIs.
>
> I don't know what you mean by legacy Windows APIs. Do you mean the "A" APIs?
> Then yes, the flag applies to those by changing the active in-process ACP
> to UTF-8.
>
> It does not change the "W" APIs, which are the preferred, non-legacy API.

The problem is knowing whether the non-Win32 API you're using is using the "W"
APIs or not. For example, does std::print()?

All three implementations available for Windows detect whether FILE * stream
in question is connected to the console and use WriteConsoleW if it is. And
they do detect if the runtime encoding of char is UTF-8, which is the default
for Clang and GCC, and you get with the /utf-8 flag that Victor mentioned.

So yes, for std::print(), that flag suffices, if you're printing to the terminal.

It should also work for std::filesystem::path because those implementations
store UTF-16 internally on Windows.

So, Herb, Christopher, if you set that MSVC flag or use a different compiler,
the new C++ APIs should work. They are designed to work. If they don't, you
have a bug with your use of them.

But as Victor says, it won't work for legacy APIs. Like open() or fopen() or
iostreams. Or the vast majority of all APIs out there. Or std::print() to a
file or pipe.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-07-03 05:20:00