Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does \u0052\u0022 start a raw string?

Tags:

c++

c++11

Let's say we have the following:

\u0052\
\u0022\u0058(Please no?)\u0058\u0022

After converting universal character names and performing line splicing, the result will be

R"X(Please no?)X"

Which is a valid raw string. According to 2.5.3, "Between the initial and final double quote characters of the raw string, any transformations performed in phases 1 and 2 are reverted":

R"\u0058(Please no?)\u0058"

Which is still a valid raw string.

Is this really how the process operates? If not, how much must be changed to make the above a valid raw string?

like image 538
Anton Golov Avatar asked Feb 22 '26 01:02

Anton Golov


1 Answers

No, that's not how the process works.

Section 2.3, paragraph 2:

... if the hexadecimal value for a universal-character-name outside the c-char-sequence, s-char-sequence, or r-char-sequence of a character or string literal corresponds to a control character ... or to a character in the basic source character set, the program is ill-formed.

So your program is ill-formed. Some compilers may choose to resolve the universal-character-names in the way you indicate, but that would be a non-standard extension.

Other than that, you've got it right. If you wrote:

R\
"\u0058(Please no?)\u0058"

The \u0058's would be reverted.

like image 192
rici Avatar answered Feb 24 '26 15:02

rici



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!