url_escape

Function encode_component

Source
pub fn encode_component<S: ?Sized + AsRef<str>>(text: &S) -> Cow<'_, str>
Expand description

Encode text used in a component.

The following characters are escaped:

C0 controls and,

  • SPACE
  • "
  • #
  • $
  • %
  • &
  • +
  • ,
  • /
  • :
  • ;
  • <
  • =
  • >
  • ?
  • @
  • [
  • \
  • ]
  • ^
  • `
  • {
  • }
  • |

and all code points greater than ~ (U+007E) are escaped.

It gives identical results to JavaScript’s encodeURIComponent().