percent_encode
Percent-encodes input for use as one URL component: a path segment, a query key or value.
Only the unreserved characters of RFC 3986 (A-Z a-z 0-9 - . _ ~) are kept; every other byte,
including /, ?, &, =, + and every byte of a non-ASCII character, becomes %XX in
upper case. It is stricter than JavaScript’s encodeURIComponent (which also leaves ! * ' ( ))
so the result is safe in any part of a URL. Returns the input borrowed when there is nothing to
encode.
Import
Section titled “Import”Cargo feature url (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input | &str | The text to encode. |
Returns
Section titled “Returns”Cow<'_, str> — The encoded text.
