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

1 assert(percentEncode("IDontNeedNoPercentEncoding") == "IDontNeedNoPercentEncoding");
2 assert(percentEncode("~~--..__") == "~~--..__");
3 assert(percentEncode("0123456789") == "0123456789");
4 
5 string e;
6 
7 e = percentEncode("☃");
8 assert(e == "%E2%98%83", "expected %E2%98%83 but got" ~ e);

Meta