base16
Base16 (hexadecimal) encoding/decoding library.
Functions
base16.decode | Decodes the specified base16 string to a string. |
base16.encode | Encodes the specified string to base16 (upper-case). |
base16.escape | Escapes the specified base16 string. |
base16.unescape | Unescapes the specified base16 string. |
base16.validate | Validates the specified base16 string. |
#base16.decode
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
| Name | Type | Description |
|---|---|---|
base16_str | string | The base16 string to decode. |
start_positionoptional | integer | The start position of the base16 string, default is 1. |
end_positionoptional | integer | The end position of the base16 string, default is the length of the base16 string. |
Returns
| Type | Name | Description |
|---|---|---|
string | raw_str | The decoded string. |
#base16.encode
function base16.encode(raw_str: string): string
Encodes the specified string to base16 (upper-case).
Parameters
| Name | Type | Description |
|---|---|---|
raw_str | string | The string to encode. |
Returns
| Type | Name | Description |
|---|---|---|
string | base16_str | The encoded string. |
#base16.escape
function base16.escape(base16_str: string): string
Escapes the specified base16 string.
Escape sequence: \xXX
Parameters
| Name | Type | Description |
|---|---|---|
base16_str | string | The base16 string to escape. |
Returns
| Type | Name | Description |
|---|---|---|
string | base16_escape_str | The escaped base16 string. |
#base16.unescape
function base16.unescape(base16_escape_str: string): string
Unescapes the specified base16 string.
Unescape sequence: \xXX
Parameters
| Name | Type | Description |
|---|---|---|
base16_escape_str | string | The base16 string to unescape. |
Returns
| Type | Name | Description |
|---|---|---|
string | base16_str | The unescaped base16 string. |
#base16.validate
function base16.validate(base16_str: string): boolean, nil | string
Validates the specified base16 string.
Parameters
| Name | Type | Description |
|---|---|---|
base16_str | string | The base16 string to validate. |
Returns
| Type | Name | Description |
|---|---|---|
boolean | is_valid | true if the base16 string is valid, otherwise false. |
nil | string | err_msg | The error message. |