You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/string-and-character-literals-cpp.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -109,9 +109,9 @@ There are three kinds of escape sequences: simple, octal, and hexadecimal. Escap
109
109
| alert (bell) |\\a |
110
110
| hexadecimal |\\xhhh |
111
111
112
-
An octal escape sequence is a backslash followed by a sequence of one to three octal digits. An octal escape sequence terminates at the first character that's not an octal digit, if encountered sooner than the third digit, and warning C4125 is generated if the character is a decimal digit. The highest possible octal value is `\377`. An octal escape sequence that has a higher value causes error C2022: '*value-in-decimal*': too big for character.
112
+
An octal escape sequence is a backslash followed by a sequence of one to three octal digits. An octal escape sequence terminates at the first character that's not an octal digit, if encountered sooner than the third digit. The highest possible octal value is `\377`.
113
113
114
-
A hexadecimal escape sequence is a backslash followed by the character `x`, followed by a sequence of hexadecimal digits. An escape sequence that contains no hexadecimal digits causes compiler error C2153: "hex literals must have at least one hex digit". Leading zeroes are ignored. In an ordinary or u8-prefixed character literal, the highest hexadecimal value is 0xFF. In an L-prefixed or u-prefixed wide character literal, the highest hexadecimal value is 0xFFFF. In a U-prefixed wide character literal, the highest hexadecimal value is 0xFFFFFFFF.
114
+
A hexadecimal escape sequence is a backslash followed by the character `x`, followed by a sequence of one or more hexadecimal digits. Leading zeroes are ignored. In an ordinary or u8-prefixed character literal, the highest hexadecimal value is 0xFF. In an L-prefixed or u-prefixed wide character literal, the highest hexadecimal value is 0xFFFF. In a U-prefixed wide character literal, the highest hexadecimal value is 0xFFFFFFFF.
115
115
116
116
This sample code shows some examples of escaped characters using ordinary character literals. The same escape sequence syntax is valid for the other character literal types.
117
117
@@ -154,17 +154,17 @@ char c1 = '\100'; // '@'
154
154
char c2 = '\1000'; // C4305, C4309, truncates to '0'
155
155
```
156
156
157
-
Escape sequences that appear to contain non-octal characters are evaluated as an octal sequence up to the last octal character, followed by the remaining characters as characters in a multicharacter literal. Warning C4125 is generated if the first non-octal character is a decimal digit. For example:
157
+
Escape sequences that appear to contain non-octal characters are evaluated as an octal sequence up to the last octal character, followed by the remaining characters as the subsequent characters in a multicharacter literal. Warning C4125 is generated if the first non-octal character is a decimal digit. For example:
158
158
159
159
```cpp
160
160
char c3 = '\009'; // '9'
161
161
char c4 = '\089'; // C4305, C4309, truncates to '9'
The highest possible octal value is `\377`. An octal escape sequence that has a higher value causes error C2022: '*value-in-decimal*': too big for character.
165
+
An octal escape sequence that has a higher value than `\377` causes error C2022: '*value-in-decimal*': too big for character.
166
166
167
-
An escape sequence that appears to have hexadecimal and non-hexadecimal characters is evaluated as a multicharacter literal that contains a hexadecimal escape sequence up to the last hexadecimal character, followed by the non-hexadecimal characters.
167
+
An escape sequence that appears to have hexadecimal and non-hexadecimal characters is evaluated as a multicharacter literal that contains a hexadecimal escape sequence up to the last hexadecimal character, followed by the non-hexadecimal characters. A hexadecimal escape sequence that contains no hexadecimal digits causes compiler error C2153: "hex literals must have at least one hex digit".
0 commit comments