escape(source: text) 🡒 text, const

Formats the argument as an Envision text literal, so that it can be directly pasted into an Envision script.

This is achieved by escaping any special characters inside the text:

Any characters outside the Unicode range U+0020 to U+007E is formatted as one or more \uXXXX sequences, for example:

The escaped text value is then surrounded with " characters. For example:

Text escape(Text)
(empty) ""
15" Screen "15\" Screen"
 Space  " Space "
Hello 🙂 "Hello \uD83D\uDE42"

The escape() function is often used to see all the contents of a text value, since the text value may otherwise contain invisible characters or spaces at the beginning or end that would be trimmed by the file or dashboard views. In the escaped text, both invisible characters and surrounding spaces are made visible.

capital = "Athens"
country = "Greece "
escapedCountry = escape("Greece ")
show scalar "Without `escape()`" a1c1 with "\{capital} is the capital city of \{country}!"
show scalar "With `escape()`" a2c2  with "\{capital} is the capital city of \{escapedCountry}!"
User Contributed Notes
0 notes + add a note