percent_decode
Decodes the %XX escapes of input.
Every % must be followed by two hexadecimal digits (either case). A + stays a +: turning
it into a space is a rule of HTML form encoding, applied by parse_query
and not by URL components in general. Returns the input borrowed when it has no %.
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 decode. |
Returns
Section titled “Returns”Result<Cow<'_, str>, PercentDecodeError> — Ok on success, otherwise an Err: see Errors.
Errors
Section titled “Errors”PercentDecodeError::InvalidEscape for a % not followed by two hex digits, and
PercentDecodeError::InvalidUtf8 when the decoded bytes are not valid UTF-8.
Examples
Section titled “Examples”Error type: PercentDecodeError
Section titled “Error type: PercentDecodeError”Why a string could not be percent-decoded.
