Handling special characters in domain names (without IDN)?

594 views Asked by At

I am using the URI class to break apart a string url.

The getHost() method returns null when there are special characters in it.

Such as: http://✪df.ws/g44

It was suggested to use the IDN class to work around this. However, that class is only available in the Android API level 9 and above, which means 2.3 and above.

Is there another way to do this without the IDN class?

I want to be able to break apart a string url into the various pieces and be able to handle modern urls.

Thanks

Update It looks like the WebView doesn't support these types of urls either. So, it looks like I need to find a way to support or convert these urls for pre 2.3 devices.

Is there a way to convert these urls without the IDN class?

1

There are 1 answers

3
Alix Axel On BEST ANSWER

getHost() = ignore everything from the start until :// and then capture everything until you get a slash.

Wouldn't that work?