Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame^] | 1 | [TOC](Readme.md) [Prev](numberlit.md) [Next](bytes.md) |
| 2 | |
| 3 | # String Literals |
| 4 | |
| 5 | CUE stings allow a richer set of escape sequences. |
| 6 | |
| 7 | CUE also supports multi-line strings, enclosed by a pair of triple quotes `"""`. |
| 8 | The opening quote must be followed by a newline. |
| 9 | The closing quote must also be on a newline. |
| 10 | The whitespace directly preceding the closing quote must match the preceding |
| 11 | whitespace on all other lines and is removed from these lines. |
| 12 | |
| 13 | Strings may also contain [interpolations](interpolation.md). |
| 14 | |
| 15 | <!-- CUE editor --> |
| 16 | ``` |
| 17 | // 21-bit unicode characters |
| 18 | a: "\U0001F60E" // 😎 |
| 19 | |
| 20 | // multiline strings |
| 21 | b: """ |
| 22 | Hello |
| 23 | World! |
| 24 | """ |
| 25 | ``` |
| 26 | |
| 27 | <!-- JSON result --> |
| 28 | ```json |
| 29 | { |
| 30 | a: "😎" |
| 31 | b: "Hello\nWorld!" |
| 32 | } |
| 33 | ``` |