C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] std::format and charN_t

From: Ivan Solovev <ivan.solovev_at_[hidden]>
Date: Tue, 11 Jun 2024 11:00:14 +0000
Hi Corentin,

> https://wg21.link/P3258
> I hope that answers some of your question

Thanks for the link. That definitely clarifies the things.

As I read it, the paper suggests to use std::text_encoding::literal()
to determine the literal encoding and fall back to the execution encoding,
if we could not get the literal encoding, of if there is no converter to
literal encoding. And then transcode all the string arguments into this
encoding. Is that correct?

Thanks,
Ivan

------------------------------

Ivan Solovev
Senior Software Engineer

The Qt Company GmbH
Erich-Thilo-Str. 10
12489 Berlin, Germany
ivan.solovev_at_[hidden]
www.qt.io

Geschäftsführer: Mika Pälsi,
Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B

________________________________________
From: Corentin Jabot <corentinjabot_at_[hidden]>
Sent: Monday, June 10, 2024 9:53 PM
To: sg16_at_[hidden]ocpp.org
Cc: Ivan Solovev
Subject: Re: [isocpp-sg16] std::format and charN_t

You don't often get email from corentinjabot_at_gmail.com. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>


On Mon, Jun 10, 2024 at 9:31 PM Ivan Solovev via SG16 <sg16_at_lists.isocpp.org<mailto:sg16_at_lists.isocpp.org>> wrote:
Hello,

I'm one of the contributors to the Qt Project, and I'm now working on adding
std::format support for Qt string types. I have some questions that I'd like
to clarify with the SG16 group.

Qt string types include:
* QString and QStringView: owning container and non-owning view on UTF-16 data
* QUtf8StringView: non-owning view on UTF-8 data
* QLatin1StringView: non-owning view on Latin1 data

What I'm trying to do is to provide std::formatter<QT_STRING_TYPE, char>
for each of the string types mentioned above.
The tricky question here is - which encoding should be used for the
generated char string?

We are discussing it in the Qt Project mailing list (link to the discussion:
https://lists.qt-project.org/pipermail/development/2024-June/045380.html),
and we're currently leaning towards encoding everything in UTF-8.
But before going forward, we wanted to check with SG16 to make sure that
we do not end up with something that will cause compatibility issues in
future.

So, my questions are:
* Are there any plans to support charN_t formatters in the standard?
* How std::formatter<charN_t, char> would behave in this case?

I've read https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2728r6.html#add-utf_view-specialization-of-formatter
and it looks like UTF-8 is the right choice if it gets accepted.
How probable is that? Are there any other papers related to this topic?

I've seen https://lists.isocpp.org/sg16/2024/05/4305.php but the link to
the draft of the paper in that email does not work for me.

https://wg21.link/P3258
I hope that answers some of your question

Cheers!


I'd appreciate any comments about the current state and future plans of
charN_t support in std::format.

Thanks,
Ivan

------------------------------

Ivan Solovev
Senior Software Engineer

The Qt Company GmbH
Erich-Thilo-Str. 10
12489 Berlin, Germany
ivan.solovev_at_[hidden]<mailto:ivan.solovev_at_qt.io>
www.qt.io<http://www.qt.io>

Geschäftsführer: Mika Pälsi,
Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
--
SG16 mailing list
SG16_at_lists.isocpp.org<mailto:SG16_at_lists.isocpp.org>
https://lists.isocpp.org/mailman/listinfo.cgi/sg16

Received on 2024-06-11 11:00:24