percentEncode

Percent-encode a string.

URL components cannot contain non-ASCII characters, and there are very few characters that are safe to include as URL components. Domain names using Unicode values use Punycode. For everything else, there is percent encoding.

@safe
string
percentEncode
(
string raw
)

Examples

assert(percentEncode("IDontNeedNoPercentEncoding") == "IDontNeedNoPercentEncoding");
assert(percentEncode("~~--..__") == "~~--..__");
assert(percentEncode("0123456789") == "0123456789");

string e;

e = percentEncode("☃");
assert(e == "%E2%98%83", "expected %E2%98%83 but got" ~ e);

Meta