-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
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-encodingorurlencodingcrate - Handle UTF-8 sequences properly
Exception
exception DecodeError {
position: int,
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels