util.string.escape

Shared

Decodes %-style numeric codepoint escapes embedded in a string


Syntax

local result = util.string.escape(
    input
)

Parameters

TypeNameDescription
stringinputString containing %-style codepoint escapes

Returns

TypeNameDescription
stringresultString with each escape sequence replaced by its actual character

Escape Forms

FormDescription
%dddDecimal codepoint (e.g. %65)
%{ddd}Decimal codepoint, explicitly bracketed
%xXX | %XXXHexadecimal codepoint
%uXXXX | %UXXXXHexadecimal codepoint (alternate form)
%%Literal percent sign

Examples

Decode a decimal codepoint escape
local result = util.string.escape("%{65}")

core.engine.print("info", result) -- 'A'
Decode a hexadecimal codepoint escape
local result = util.string.escape("%x41")

core.engine.print("info", result) -- 'A'
Decode escapes mixed with plain text
local result = util.string.escape("100%{37} done")

core.engine.print("info", result) -- '100% done'

On this page