[format.string.escaped] (original) (raw)

28 Text processing library [text]

28.5 Formatting [format]

28.5.6 Formatter [format.formatter]

28.5.6.5 Formatting escaped characters and strings [format.string.escaped]

A character or string can be formatted as escapedto make it more suitable for debugging or for logging.

The escaped string E representation of a string _S_is constructed by encoding a sequence of characters as follows.

The associated character encoding _CE_for charT (Table 12) is used to both interpret S and construct E.

Table 112 β€” Mapping of characters to escape sequences [tab:format.escape.sequences]

πŸ”—Character Escape sequence
πŸ”—U+0009 character tabulation \t
πŸ”—U+000a line feed \n
πŸ”—U+000d carriage return \r
πŸ”—U+0022 quotation mark \"
πŸ”—U+005c reverse solidus \\

The escaped string representation of a character _C_is equivalent to the escaped string representation of a string of C, except that:

[Example 1: string s0 = format("[{}]", "h\tllo"); string s1 = format("[{:?}]", "h\tllo"); string s2 = format("[{:?}]", "Бпасибо, Π’ΠΈΠΊΡ‚ΠΎΡ€ β™₯!"); string s3 = format("[{:?}, {:?}]", '\'', '"'); string s4 = format("[{:?}]", string("\0 \n \t \x02 \x1b", 9)); string s5 = format("[{:?}]", "\xc3\x28"); string s6 = format("[{:?}]", "πŸ€·πŸ»β€β™‚οΈ"); string s7 = format("[{:?}]", "\u0301"); string s8 = format("[{:?}]", "\\\u0301"); string s9 = format("[{:?}]", "e\u0301\u0323"); β€” _end example_]