#url #percent #escape #urlencode #urldecode

urlencoding

A Rust library for doing URL percentage encoding

5 releases (3 stable)

1.1.1 Jun 17, 2020
1.0.0 May 9, 2017
0.2.0 Sep 16, 2016
0.1.1 Sep 15, 2016
0.1.0 Sep 15, 2016

#21 in Encoding

Download history 35540/week @ 2020-11-04 38186/week @ 2020-11-11 38227/week @ 2020-11-18 32544/week @ 2020-11-25 39985/week @ 2020-12-02 40496/week @ 2020-12-09 34861/week @ 2020-12-16 22676/week @ 2020-12-23 24315/week @ 2020-12-30 36043/week @ 2021-01-06 35253/week @ 2021-01-13 31864/week @ 2021-01-20 32460/week @ 2021-01-27 28035/week @ 2021-02-03 29575/week @ 2021-02-10 31160/week @ 2021-02-17

126,389 downloads per month
Used in 218 crates (65 directly)

MIT license

9KB
156 lines

urlencoding

Latest Version

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 urlencoding::encode;

fn main() {
  let encoded = encode("This string will be URL encoded.");
  println!("{}", encoded);
  // This%20string%20will%20be%20URL%20encoded.
}

To decode a string, it's only slightly different:

use urlencoding::decode;

fn main() {
  let decoded = decode("%F0%9F%91%BE%20Exterminate%21");
  println!("{}", decoded.unwrap());
  // 👾 Exterminate!
}

License

This project is licensed under the MIT license, Copyright (c) 2017 Bertram Truong. For more information see the LICENSE file.

No runtime deps