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".Noneif it isn’t valid Punycode, or decodes to overMAX_LABELcode points. - encode_
str - Encodes a label as Punycode:
"bücher"becomes"bcher-kva".Nonemeans the arithmetic overflowed, or the label is overMAX_LABEL.