Skip to content

encoding.punycode

fn decode #

fn decode(input string) !string

decode returns the string that input encodes, expecting input without the xn-- prefix.

Both letter cases are accepted, as RFC 3492 requires of a decoder.

fn encode #

fn encode(input string) !string

encode returns the Punycode form of input, without the xn-- prefix.

The basic code points of input are emitted first, in order, followed by a delimiter if there were any, followed by the deltas that reinsert the remaining code points. Encoding a string that is already entirely ASCII therefore appends a trailing delimiter, which is what the format requires and what an IDNA layer is expected to avoid asking for.