type | prefix |
---|---|
<none> | string |
r, R | string |
w, W | wstring |
u, U | ustring |
c, C | charcp |
The prefix is followed by the string which is delimited by the following quotation marks:
name | code | mark |
---|---|---|
single-quote | q | ' |
double-quote | d | " |
tripled-single-quote | qqq | ''' |
tripled-double-quote | ddd | """ |
The r or R prefix designates a raw string, which consists of the whole of the string up to the next matching delimiter, there is no escape processing.
Other string process escapes as follows.
Escape | Result |
---|---|
\a | 7, ASCII Bell |
\b | 8, ASCII Backspace |
\t | 9, ASCII Tab |
\n | 10, ASCII Linefeed |
\v | 11, ASCII Vertical Tab |
\f | 12, ASCII Form Feed |
\r | 13, ASCII Carriage Return |
\e | 33, ASCII Escape |
\\ | \ |
\" | " |
\' | ' |
\ | See Notes |
\o | See Notes |
\d | See Notes |
\x | See Notes |
\u | See Notes |
\U | See Notes |
The escapes \o, \d and \x are octal, decimal, and hex code point encodings. They encode a single character from the octal, decimal, or hex numeric digits following, respectively, up to the first non-digit or the encoding limits 3, 3, 2 respectively.
The \u and \U escapes are used to interpret longer hex escapes, up to 4 or 8 digits respectively. However whereas in a ustring literal the numeric value is a single character, in a string it is replaced by the UTF8 encoding of the value.
Therefore, unicode strings, whether stored in a string or ustring, have the same interpretation as unicode, provided the all characters presented literally or via \o, \d or \x encodings, have unicode value less than 128 (that is, they're plain ASCII).
The intepretation of wstring literals is platform independent and undefined by Felix at this time.
Note that C style octal escapes are NOT ALLOWED.
If an escape code is followed by any character other than those listed, the result is undefined. The current implementation preserves the sequence (including the leading slosh).