Module: encoding.url
Source: ./encoding/url.reef
Overview
encoding/url - URL percent encoding and decoding
Implements RFC 3986 percent-encoding for URLs. Unreserved characters (A-Z, a-z, 0-9, -_.~) are not encoded. All other characters are encoded as %XX where XX is the hex value.
Usage: import encoding.url let encoded = url_encode("Hello World!") // "Hello%20World%21" let decoded = url_decode("Hello%20World%21") // "Hello World!"
Functions
fn get_hex_upper(): string
Hex digits for encoding
fn is_unreserved(c: char): bool
Check if character is unreserved (RFC 3986) Unreserved = A-Z / a-z / 0-9 / - / . / _ / ~
fn is_hex_digit(c: char): bool
Check if character is a valid hex digit
fn hex_value(c: char): int
Convert hex character to value (0-15)
fn count_encoded_length(s: string, encode_reserved: bool): int
Count how many bytes the encoded string will need
fn url_encode(s: string): string
Standard URL encoding - keeps path-safe characters
fn url_encode_component(s: string): string
Component encoding - encodes everything except unreserved
fn url_encode_form(s: string): string
Form encoding - like component but spaces become +
fn count_decoded_length(s: string): int
Count decoded length
fn url_decode(s: string): string
Standard URL decoding
fn url_decode_form(s: string): string
Form decoding - + becomes space
fn url_is_valid_encoded(s: string): bool
Check if string is validly percent-encoded
Generated by reefc doc