percentDecode

Percent-decode 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.

This explicitly ensures that the result is a valid UTF-8 string.

@safe @trusted
string
percentDecode
(
string encoded
)

Examples

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

Meta