urlencoding
A tiny Rust library for doing URL percentage encoding and decoding. It percent-encodes everything except alphanumerics and -, _, ., ~.
When decoding + is not treated as a space. Error recovery from incomplete percent-escapes follows the WHATWG URL standard.
Usage
To encode a string, do the following:
use encode;
let encoded = encode;
println!;
// This%20string%20will%20be%20URL%20encoded.
To decode a string, it's only slightly different:
use decode;
let decoded = decode?;
println!;
// 👾 Exterminate!
To decode allowing arbitrary bytes and invalid UTF-8:
use decode_binary;
let binary = decode_binary;
let decoded = Stringfrom_utf8_lossy;
This library returns Cow to avoid allocating when decoding/encoding is not needed. Call .into_owned() on the Cow to get a Vec or String.
License
This project is licensed under the MIT license. For more information see the LICENSE file.