Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


1656. Encoding of numerically-escaped characters

Section:5.13.3  [lex.ccon]    Status:CD6    Submitter:Mike Miller    Date:2013-04-30

[Accepted at the November, 2020 meeting as part of paper P2029R4.]

According to 5.13.3 [lex.ccon] paragraph 4,

The escape\ooo consists of the backslash followed by one, two, orthree octal digits that are taken to specify the value of the desiredcharacter. The escape\xhhh consists of the backslash followedbyx followed by one or more hexadecimal digits that are taken tospecify the value of the desired character. There is no limit to the numberof digits in a hexadecimal sequence. A sequence of octal or hexadecimaldigits is terminated by the first character that is not an octal digit or ahexadecimal digit, respectively. The value of a character literal isimplementation-defined if it falls outside of the implementation-definedrange defined forchar (for literals with noprefix),char16_t (for literals prefixedby'u'),char32_t (for literals prefixedby'U'), orwchar_t (for literals prefixedby'L').

It is not clearly stated whether the “desired character”being specified reflects the source or the target encoding. Thisparticularly affects UTF-8 string literals (5.13.5 [lex.string] paragraph 7):

A string literal that begins withu8, such asu8"asdf",is a UTF-8 string literal and is initialized with the given characters asencoded in UTF-8.

For example, assuming the source encoding is Latin-1, isu8"\xff" supposed to specify a three-byte string whosefirst two bytes are0xc3 0xbf (the UTF-8 encoding of\u00ff) or a two-byte string whose first byte has thevalue0xff? (At least some current implementations assume thelatter interpretation.)

Notes from the September, 2013 meeting:

The second interpretation (that the escape sequence specifies theexecution-time code unit) is intended.




[8]ページ先頭

©2009-2026 Movatter.jp