[][src]Function askama::filters::urlencode

pub fn urlencode(s: &dyn Display) -> Result<String, Error>

Percent-encodes the argument for safe use in URI; does not encode /

This should be safe for all parts of URI (paths segments, query keys, query values). In the rare case that the server can't deal with forward slashes in the query string, use urlencode_strict, which encodes them as well.

Encodes all characters except ASCII letters, digits, and _.-~/. In other words, encodes all characters which are not in the unreserved set, as specified by RFC3986, with the exception of /.

<a href="/metro{{ "/stations/Château d'Eau" | urlencode }}">Station</a>
<a href="/page?text={{ "look, unicode/emojis ✨" | urlencode }}">Page</a>

To encode / as well, see urlencode_strict.