Expand description
URL percent-encoding and decoding for byte slices and strings.
Encodes bytes as %XX sequences using the unreserved character set from
RFC 3986 (A–Z, a–z, 0–9, -, _, ., ~). All other bytes are encoded.
Decoding accepts both %XX (hex escape) and + (space, form-data style).
§Features
encode— percent-encode a string (query-string safe).encode_bytes— percent-encode raw bytes.decode— decode a percent-encoded string; returnsErron malformed input.decode_lossy— decode and replace invalid sequences with the literal%XXtext.DecodeError— structured error type for malformed input.
§Quick Start
use rune_url_encode::{encode, decode};
let encoded = encode("hello world/path?q=1");
assert_eq!(encoded, "hello%20world%2Fpath%3Fq%3D1");
let decoded = decode(&encoded).unwrap();
assert_eq!(decoded, "hello world/path?q=1");§CLI
rune-url-encode "hello world" # encode
rune-url-encode -d "hello%20world" # decodeEnums§
- Decode
Error - Error returned when
decodeencounters malformed percent-encoded input.
Functions§
- decode
- Decodes a percent-encoded string.
- decode_
lossy - Decodes a percent-encoded string, keeping malformed
%XXsequences as-is. - encode
- Percent-encodes a string, escaping all characters outside the RFC 3986
unreserved set (
A–Z a–z 0–9 - _ . ~). - encode_
bytes - Percent-encodes raw bytes, escaping all bytes outside the RFC 3986 unreserved set.