Skip to main content

Crate punycode_rs

Crate punycode_rs 

Source
Expand description

A Rust port of Punycode (RFC 3492), the ASCII-compatible encoding at the heart of Internationalized Domain Names — e.g. münchen <-> mnchen-3ya.

Port target: Python’s standard library encodings/punycode.py (Martin v. Löwis). Verified against Python’s built-in punycode codec.

The algorithm separates a string into its ASCII “base” and its sorted non-ASCII characters, then encodes each non-ASCII character as a single integer “delta” that records both which character and where it is inserted. Deltas are written as base-36 generalized variable-length integers with an adaptive bias that self-tunes for compactness. Decoding mirrors the process exactly.

Enums§

PunycodeError
An error from decode.

Functions§

decode
Decode a Punycode string back to Unicode. Input must be ASCII.
encode
Encode a string to Punycode (RFC 3492). Pure-ASCII input gains a trailing -.