Java - accent node name InetSocketAddress

I had a problem establishing a connection to the server with some accents (é è ô ...) in the host name.

For instance:

String oUrl = "www.hôtel.fr";   
System.out.println(oUrl);
InetSocketAddress isa = new InetSocketAddress(oUrl.toString(), 80);
System.out.println(isa.isUnresolved());

ISA is never allowed. He works at www.google.fr.

I tried to execute the URLEncode host (URLEncoder encoded in UTF-8, so the host name is www.h% C3% B4tel.fr) with no result.

Does anyone have any clues? I did not find anything on the Internet.

Thanks and sorry for my english.

+5
source share
1 answer

In domain names, umlauts, accents, etc. must be converted using punycode. In your example, it will be http://www.xn--htel-vqa.fr/. Without testing, the IDN class can help.

+3
source

All Articles