Function urlparse::quote [] [src]

pub fn quote<S: AsRef<str>>(s: S, safe: &[u8]) -> Result<String, FromUtf8Error>

Replaces special characters in string using the %xx escape. Letters, digits, and the characters '_.-' are never quoted.

Examples

use urlparse::quote;

let s = quote("test@example.com", b"");
assert_eq!(s.ok().unwrap(), "test%40example.com");
let path = quote("/a/b/c", b"/");
assert_eq!(path.ok().unwrap(), "/a/b/c");
let ss = quote("|abc|".to_string(), b"/");
assert_eq!(ss.ok().unwrap(), "%7Cabc%7C");