Skip to main content

Crate rune_url_encode

Crate rune_url_encode 

Source
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; returns Err on malformed input.
  • decode_lossy — decode and replace invalid sequences with the literal %XX text.
  • 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" # decode

Enums§

DecodeError
Error returned when decode encounters malformed percent-encoded input.

Functions§

decode
Decodes a percent-encoded string.
decode_lossy
Decodes a percent-encoded string, keeping malformed %XX sequences 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.