percent_encode

Function percent_encode 

Source
pub fn percent_encode(input: &str) -> String
Expand description

What: Percent-encode a string for use in URLs according to RFC 3986.

Inputs:

  • input: String to encode.

Output:

  • Returns a percent-encoded string where reserved characters are escaped.

Details:

  • Unreserved characters as per RFC 3986 (A-Z, a-z, 0-9, -, ., _, ~) are left as-is.
  • Space is encoded as %20 (not +).
  • All other bytes are encoded as two uppercase hexadecimal digits prefixed by %.
  • Operates on raw bytes from the input string; any non-ASCII bytes are hex-escaped.