C++ Logo

std-proposals

Advanced search

Re: +AFs-std-proposals+AF0 Newlines in F-strings

From: Hadriel Kaplan <hkaplan_at_[hidden]>
Date: Wed, 25 Oct 2023 01:10:50 +0000
Juniper Public
+AD4- From: Std-Proposals +ADw-std-proposals-bounces+AEA-lists.isocpp.org +ADw-mailto:std-proposals-bounces+AEA-lists.isocpp.org+AD4APg- on behalf of Chris Gary via Std-Proposals +ADw-std-proposals+AEA-lists.isocpp.org +ADw-mailto:std-proposals+AEA-lists.isocpp.org+AD4APg-
+AD4- Date: Tuesday, October 24, 2023 at 7:43 PM

+AD4- Chances are I missed this earlier, but in the case of a raw literal, how is a literal +ACIAewAi- or +ACIAfQAi- given?
+AD4- It looks as though that could be the only special case here, where escaping would just be +ACIAXAB7ACI- or +ACIAXAB9ACI-.
+AD4- Am I correct here?

The +ACI-escaping+ACI- of braces is purely for the format-string syntax handling, not string-literals themselves.

So you don't use +ACIAXAB7ACI- to +ACI-escape+ACI- braces in a raw-string - you keep using double-braces to escape them, regardless of it being a raw or non-raw string.


I.e., this raw-string:

FR+ACI-(name+AD0AewB7-foo+AH0AfQ-)+ACIAOw-

Is identical to this non-raw-string:

F+ACI-name+AD0AewB7-foo+AH0AfQAiADs-

Which produces this interpolated output:

std::format(+ACI-name+AD0AewB7-foo+AH0AfQAi-)+ADs-

Which ultimately generates this in a std::string:

+ACI-name+AD0Aew-foo+AH0AIg-


Whereas both of these:

FR+ACI-(name+AD0Aew-foo+AH0-)+ACIAOw-
F+ACI-name+AD0Aew-foo+AH0AIgA7-

Produce this:

std::format(+ACI-name+AD0AewB9ACI-, foo)+ADs-


-hadriel

Received on 2023-10-25 01:10:57