std.itoa_charset

STRINGstd.itoa_charsetINTEGERvalueSTRINGcharset

Available inall subroutines.

Converts the integer value to a string in the character set charset.

The charset value must be at least two characters in length. The length of the character set is the numeric base of the conversion, so "0123456789ABCDEF" converts to base 16 (hexadecimal) using uppercase letters. Repeated characters are permitted.

Base prefixes, such as hexadecimal (0x) and octal (0), are not included.

Errors

If the charset argument is not set or has fewer than two characters, then fastly.error will be set to EINVAL.

Example

# binary, but sheep: "baaa"
std.itoa_charset(8, "ab")
# hexadecimal in uppercase: "DEADBEEF"
std.itoa_charset(0xdeadbeef, "0123456789ABCDEF")
# arbitrary Base62, sometimes used for URL-safe encoding: "5KsxueeBfd8"
std.itoa_charset(4825434263756878946, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")