Skip to content

Add std::encoding::url module #52

@mjm918

Description

@mjm918

Summary

Add URL encoding/decoding (percent-encoding) support as part of the std::encoding module.

Parent issue: #48

Functions

Function Signature Description
encode (s: string) -> string URL-encode a string
decode (s: string) -> string throws DecodeError URL-decode a string

Usage

use std::encoding::url::*;

var safe: string = encode("hello world & more");  // "hello%20world%20%26%20more"
var original: string = decode(safe);

// With error handling  
var text: string = decode("%ZZ") catch e {
    println(e.message);
    return;
} ?? "";

Implementation Notes

  • Encode all characters except unreserved characters (A-Z, a-z, 0-9, -, _, ., ~)
  • Use Rust's percent-encoding or urlencoding crate
  • Handle UTF-8 sequences properly

Exception

exception DecodeError {
    position: int,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions