Skip to main content

Module punycode

Module punycode 

Source
Expand description

RFC 3492 Punycode, one label at a time and without the xn-- prefix.

use parsec_url::punycode;

assert_eq!(punycode::encode_str("bücher").unwrap(), "bcher-kva");
assert_eq!(punycode::decode_to_string("bcher-kva").unwrap(), "bücher");

Constants§

MAX_LABEL
The longest label, in code points, that’s encoded or decoded to. Both take time that grows with the square of a label’s length; past this a label fails, as the arithmetic overflowing does. A label in DNS is at most 63 bytes, so no real one comes near it.

Functions§

decode_to_string
Decodes a Punycode label: "bcher-kva" becomes "bücher". None if it isn’t valid Punycode, or decodes to over MAX_LABEL code points.
encode_str
Encodes a label as Punycode: "bücher" becomes "bcher-kva". None means the arithmetic overflowed, or the label is over MAX_LABEL.