Special characters can be included in string literals using the following escape sequences:
The following example shows how to use a few string literals:
Swift 4
Escape sequence | Meaning |
---|---|
\0 | Null Character |
\\ | \character |
\b | Backspace |
\f | Form feed |
\n | Newline |
\r | Carriage return |
\t | Horizontal tab |
\v | Vertical tab |
\’ | Single Quote |
\” | Double Quote |
\000 | Octal number of one to three digits |
\xhh… | Hexadecimal number of one or more digits |