encoding
Base64/hex/URL text codecs.
Naming convention: import the module under its bare name (
import "encoding"), reach members with a backslash, and call methods incamelCase:encoding\someMethod.
Methods
base64Encode
Encode data as standard (padded) base64.
Signature: encoding\base64Encode(data) → string1 · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
data |
string |
Returns: string
base64Decode
Decode a standard (padded) base64 string; errors on malformed input.
Signature: encoding\base64Decode(s) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
s |
string |
Returns: string
base64urlEncode
Encode data as URL-safe (padded) base64.
Signature: encoding\base64urlEncode(data) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
data |
string |
Returns: string
base64urlDecode
Decode a URL-safe (padded) base64 string; errors on malformed input.
Signature: encoding\base64urlDecode(s) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
s |
string |
Returns: string
hexEncode
Encode data as lowercase hex.
Signature: encoding\hexEncode(data) → string2 · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
data |
string |
Returns: string
hexDecode
Decode a hex string; errors on malformed input.
Signature: encoding\hexDecode(s) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
s |
string |
Returns: string
urlEncode
Percent-encode s for use in a URL query component.
Signature: encoding\urlEncode(s) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
s |
string |
Returns: string
urlDecode
Decode a percent-encoded URL query component; errors on malformed input.
Signature: encoding\urlDecode(s) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
s |
string |
Returns: string
parseUrl
Parse a URL string into {scheme, host, port, path, query, fragment}; errors on malformed input.
Signature: encoding\parseUrl(raw_url) → URL · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
raw_url |
string |
Returns: map[string]any
buildUrl
Build a URL string from a URL object - the same shape parse_url returns, so the two round-trip. Missing fields are treated as empty.
Signature: encoding\buildUrl(parts) → string · source
| Parameter | Type | Optional | Description |
|---|---|---|---|
parts |
map[string]any |
Returns: string