Available inall subroutines.

Escapes bytes from a string using C-style escape sequences.

The escaping rules in priority order are as follows:

  1. if the byte is the double quote (0x22), it is escaped as \" (backslash double quote)
  2. if the byte is the backslash (0x5C), it is escaped as \\ (double backslash)
  3. if the byte is one of the following control characters, it is escaped as follows:
  • \b (0x08, backspace)
  • \t (0x09, horizontal tab)
  • \n (0x0A, newline)
  • \v (0x0B, vertical tab)
  • \r (0x0D, carriage return)
  1. 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 \xHH where HH is the hexadecimal value of the byte
  2. if none of the above matched, the byte is passed through as-is: for example a for 0x61

HINT: If you are escaping JSON strings, use json.escape instead.

This function is not prefixed with the std. namespace.


# var.escaped is set to: city="london"
declare local var.escaped STRING;
set var.escaped = "city=%22" + cstr_escape(client.geo.city.ascii) + "%22";