Function parse_string

Source
pub fn parse_string(s: &str) -> Result<String, ParseSequenceError>
Expand description

Parse the provided quoted string. This function was adopted from snailquote.

§Details

Parses a single or double quoted string and interprets escape sequences such as ‘\n’, ‘\r’, ‘'’, etc.

Supports raw strings prefixed with r or R in which case all escape sequences are ignored.///

The full set of supported escapes between quotes may be found below:

EscapeCodeDescription
\a0x07Bell
\b0x08Backspace
\v0x0BVertical tab
\f0x0CForm feed
\n0x0ANewline
\r0x0DCarriage return
\t0x09Tab
\0x5CBackslash
?0x??Question mark
"0x22Double quote
'0x27Single quote
`0x60Backtick
\xDD0xDDUnicode character with hex code DD
\uDDDD0xDDDDUnicode character with hex code DDDD
\UDDDDDDDD0xDDDDDDDDUnicode character with hex code DDDDDDDD
\DDD0DDDUnicode character with octal code DDD

§Errors

The returned result can display a human readable error if the string cannot be parsed as a valid quoted string.