URI.encode
You're seeing just the function
encode
, go back to URI module for more information.
Specs
encode(binary(), (byte() -> as_boolean(term()))) :: binary()
Percent-escapes all characters that require escaping in string
.
This means reserved characters, such as :
and /
, and the
so-called unreserved characters, which have the same meaning both
escaped and unescaped, won't be escaped by default.
See encode_www_form/1
if you are interested in escaping reserved
characters too.
This function also accepts a predicate
function as an optional
argument. If passed, this function will be called with each byte
in string
as its argument and should return a truthy value (anything other
than false
or nil
) if the given byte should be left as is, or return a
falsy value (false
or nil
) if the character should be escaped. Defaults
to URI.char_unescaped?/1
.
Examples
iex> URI.encode("ftp://s-ite.tld/?value=put it+й")
"ftp://s-ite.tld/?value=put%20it+%D0%B9"
iex> URI.encode("a string", &(&1 != ?i))
"a str%69ng"