dreamworkAPI
Ctrl K
GitHub
libraryDocs / base16

base16

librarysharedmenusource

Base16 (hexadecimal) encoding/decoding library.

See https://en.wikipedia.org/wiki/Hexadecimal

Functions

base16.decodeDecodes the specified base16 string to a string.
base16.encodeEncodes the specified string to base16 (upper-case).
base16.escapeEscapes the specified base16 string.
base16.unescapeUnescapes the specified base16 string.
base16.validateValidates the specified base16 string.

#base16.decode

sharedmenunodiscardsource
function base16.decode(base16_str: string, start_position?: integer, end_position?: integer): string

Decodes the specified base16 string to a string.

Pairs that are not valid hex digits and a trailing odd character are copied as-is, use base16.validate to reject them.

Parameters
NameTypeDescription
base16_strstringThe base16 string to decode.
start_positionoptionalintegerThe start position of the base16 string, default is 1.
end_positionoptionalintegerThe end position of the base16 string, default is the length of the base16 string.
Returns
TypeNameDescription
stringraw_strThe decoded string.

#base16.encode

sharedmenunodiscardsource
function base16.encode(raw_str: string): string

Encodes the specified string to base16 (upper-case).

Parameters
NameTypeDescription
raw_strstringThe string to encode.
Returns
TypeNameDescription
stringbase16_strThe encoded string.

#base16.escape

sharedmenunodiscardsource
function base16.escape(base16_str: string): string

Escapes the specified base16 string.

Escape sequence: \xXX

Parameters
NameTypeDescription
base16_strstringThe base16 string to escape.
Returns
TypeNameDescription
stringbase16_escape_strThe escaped base16 string.

#base16.unescape

sharedmenunodiscardsource
function base16.unescape(base16_escape_str: string): string

Unescapes the specified base16 string.

Unescape sequence: \xXX

Parameters
NameTypeDescription
base16_escape_strstringThe base16 string to unescape.
Returns
TypeNameDescription
stringbase16_strThe unescaped base16 string.

#base16.validate

sharedmenunodiscardsource
function base16.validate(base16_str: string): boolean, nil | string

Validates the specified base16 string.

Parameters
NameTypeDescription
base16_strstringThe base16 string to validate.
Returns
TypeNameDescription
booleanis_validtrue if the base16 string is valid, otherwise false.
nil | stringerr_msgThe error message.
Generated from the dreamwork meta branch.