turbo.escape – Escaping and JSON utilities

JSON conversion

json_encode(t)

JSON stringify a table. May raise a error if table could not be decoded.

Parameters:t – Value to JSON encode.
Return type:String
json_decode(s)

Decode a JSON string to table.

Parameters:s (String) – JSON enoded string to decode into Lua primitives.
Return type:Table

Escaping

unescape(s)

Unescape a escaped hexadecimal representation string.

Parameters:s (String) – String to unescape.
Return type:String
escape(s)

Encodes a string into its escaped hexadecimal representation.

Parameters:s (String) – String to escape.
Return type:String
html_escape(s)

Encodes the HTML entities in a string. Helpfull to avoid XSS.

Parameters:s (String) – String to escape.
Return type:String

String trimming

trim(s)

Remove trailing and leading whitespace from string.

Parameters:s – String
Return type:String
ltrim(s)

Remove leading whitespace from string.

Parameters:s – String
Return type:String
rtrim(s)

Remove trailing whitespace from string.

Parameters:s – String
Return type:String