Special characters that can be included in a Swift String ?

By | January 5, 2018

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

Leave a Reply

Your email address will not be published. Required fields are marked *