简体   繁体   中英

Handling special characters in domain names (without IDN)?

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?

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

Wouldn't that work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM