Skip to content

Handling URLs with non-ascii chars? #381

Answered by sagebind
troelsarvin asked this question in Questions
Discussion options

You must be logged in to vote

It appears that you are right, http::Uri does not handle IDNA translation for domain names by itself, so you would need to do that manually first. You could do that with the idna crate today:

fn main() {
    let domain = "sejs-svejbækbiler.dk";
    let url = format!("https://{}/", idna::domain_to_ascii(domain).unwrap());
    let response = isahc::get(url);
    if let Err(e) = response {
        println!("Error: {:?}", e);
    }
}

I agree that this is not an ideal experience and it should be handled better in the future, but this should work as a workaround for the current version. Ideally, this would be handled in the http crate upstream, perhaps as an optional feature.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by troelsarvin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants