#urlencode #url #encode #decode #percent

app urlencode

A CLI utility for URL-encoding or -decoding strings

5 releases (2 stable)

Uses new Rust 2021

1.0.1 May 21, 2022
0.1.2 May 7, 2019
0.1.1 Feb 12, 2018
0.1.0 Aug 11, 2017

#173 in Encoding

Download history 22/week @ 2022-03-15 18/week @ 2022-03-22 10/week @ 2022-03-29 15/week @ 2022-04-05 12/week @ 2022-04-12 9/week @ 2022-04-19 33/week @ 2022-04-26 28/week @ 2022-05-03 65/week @ 2022-05-10 86/week @ 2022-05-17 54/week @ 2022-05-24 61/week @ 2022-05-31 24/week @ 2022-06-07 17/week @ 2022-06-14 16/week @ 2022-06-21 20/week @ 2022-06-28

85 downloads per month

MIT license

8KB
162 lines

urlencode

urlencode is a CLI utility for URL-encoding or -decoding strings.

Usage

You can give it a positional argument for a single string, or you can pipe input to it from stdin.

$ urlencode 'foo bar'
foo%20bar

$ echo -e "foo bar\nbaz quux" | urlencode
foo%20bar
baz%20quux

You can pass -d or --decode to decode the input.

$ urlencode -d 'foo%20bar'
foo bar

$ echo -e "foo%20bar\nbaz%20quux" | urlencode -d
foo bar
baz quux

Run urlencode --help to see all options.

Encode sets

Since different parts of a URL have different encoding requirements, there are many encode sets to choose from. See this documentation page for an explanation of each. They can be specified with the -e or --encode-set option:

$ echo 'https://docs.rs/percent-encoding/1.0.0/percent_encoding/index.html' | urlencode -e path
https:%2F%2Fdocs.rs%2Fpercent-encoding%2F1.0.0%2Fpercent_encoding%2Findex.html

$ echo 'https://docs.rs/percent-encoding/1.0.0/percent_encoding/index.html' | urlencode -e userinfo
https%3A%2F%2Fdocs.rs%2Fpercent-encoding%2F1.0.0%2Fpercent_encoding%2Findex.html
----

Cargo

You can install with Cargo with:

cargo install urlencode

Dependencies

~1.5MB
~31K SLoC