Closed dandyvica closed 10 months ago
encode_str should only be used for a single label.
use idna; // 0.4.0
fn main() {
let x = idna::domain_to_ascii("ουτοπία.δπθ.gr");
println!("{:?}", x);
let x = idna::punycode::encode_str("ουτοπία.δπθ.gr");
println!("{:?}", x);
let x = idna::punycode::encode_str("ουτοπία");
println!("{:?}", x);
}
Output:
Ok("xn--kxae4bafwg.xn--pxaix.gr")
Some("..gr-pldmw6azdale9bn")
Some("kxae4bafwg")
I suppose we could make encode_into return an Err if the input contains any dots here, but that shouldn't really be necessary if you use idna::domain_to_ascii instead.
@valenting Thanks a lot for the explanation !
Describe the bug
encode_str("ουτοπία.δπθ.gr")
gives..gr-pldmw6azdale9bn
Online decoders give
xn--kxae4bafwg.xn--pxaix.gr
What's wrong?