blob: 817fced9c4252262bb1f523fc9404f8d1827e099 [file] [log] [blame]
cue eval stringraw.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "\"Raw\" Strings"
description = ""
-- text.md --
CUE does not support raw strings in the strictest sense.
Instead it allows modifying the escape delimiter by requiring
an arbitrary number of hash `#` signs after the backslash by
enclosing a string literal in an equal number of hash signs on either end.
This works for normal and interpolated strings.
Quotes do not have to be escaped in such strings.
-- stringraw.cue --
msg1: #"The sequence "\U0001F604" renders as \#U0001F604."#
msg2: ##"""
A regular expression can conveniently be written as:
#"\d{3}"#
This construct works for bytes, strings and their
multi-line variants.
"""##
-- expect-stdout-cue --
msg1: "The sequence \"\\U0001F604\" renders as 😄."
msg2: """
A regular expression can conveniently be written as:
#\"\\d{3}\"#
This construct works for bytes, strings and their
multi-line variants.
"""