String literals
Standard string literals
A string literal is a sequence of characters enclosed within single quotes (’). For example,'Database'
is a string literal.
To include a single-quote character within a string literal, you can use two consecutive single quotes. For example, 'Stream processing''s advantages'
is a valid string literal that incorporates a single-quote character.
String literals with C-style escapes
String literals with C-style escapes use escape sequences to represent special characters within a string, just as in the C programming language. These literals are constructed by prepending the lettere
to the string literal. For example, e'abc\n\tdef'
.
The following escape sequences are supported:
Escape sequence | Interpretation |
---|---|
\b | backspace |
\f | form feed |
\n | newline |
\r | carriage return |
\t | tab |
\o, \oo, \ooo (o = 0–7) | octal byte value |
\xh, \xhh (h = 0–9, A–F) | hexadecimal byte value |
\uXXXX (x = 0–9, A–F) | 16-bit hexadecimal Unicode character value |
\UXXXXXXXX (x = 0–9, A–F) | 32-bit hexadecimal Unicode character value |