Lyricdev
GitHub

struct Percent

pub struct Percent

Percent-encoding (§2.1): a text for one Component, each byte the component does not keep written as % and two hex digits.

Methods

pub static fn encode(s: StringView, c: Component): string

Returns s percent-encoded for the component c (§2.1): every byte the component does not keep becomes % and two hex digits in capitals; a character beyond ASCII is encoded as the bytes of its UTF-8.

pub static fn decode(s: StringView): string throws ParseError

Returns s with its percent-encodings decoded, each % and two hex digits one byte. A + stays a +; Query.parse is the one that reads it as a space, the form convention.

Errors

Throws ParseError with kind Invalid for a % without two hex digits after it, and for decoded bytes that are not UTF-8.