Available in all subroutines.
Escapes bytes from a string using C-style escape sequences.
The escaping rules in priority order are as follows:
- if the byte is the double quote (0x22), it is escaped as
\"(backslash double quote)
- if the byte is the backslash (0x5C), it is escaped as
- if the byte is one of the following control characters, it is escaped as follows:
\t(0x09, horizontal tab)
\v(0x0B, vertical tab)
\r(0x0D, carriage return)
- if the byte is less than or equal to 0x1F, or it is greater or equal to 0x7F
(in other words, a control character not explicitly listed above),
it is escaped as
\xHHwhere HH is the hexadecimal value of the byte
- if none of the above matched, the byte is passed through as-is:
HINT: If you are escaping JSON strings, use
This function is not prefixed with the
# var.escaped is set to: city="london"declare local var.escaped STRING;set var.escaped = "city=%22" + cstr_escape(client.geo.city.ascii) + "%22";
User contributed notes
We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.