encode

Encodes the UTF-8 string uri into a URI and returns that URI. Any character not a valid URI character is escaped. The '#' character is not escaped.

string
encode
(
Char
)
(
scope const(Char)[] uri
)
if ()

Examples

assert("foo bar".encode == "foo%20bar");
assert("<>.@.™".encode == "%3C%3E.@.%E2%84%A2");
assert("foo/#?a=1&b=2".encode == "foo/#?a=1&b=2");
assert("dlang+rocks!".encode == "dlang+rocks!");
assert("!@#$%^&*(".encode == "!@#$%25%5E&*(");

Meta