1

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?

Community
  • 1
  • 1
cottonBallPaws
  • 21,220
  • 37
  • 123
  • 171

1 Answers1

1

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

Wouldn't that work?

Alix Axel
  • 151,645
  • 95
  • 393
  • 500
  • I guess that would work, I was trying to use the URI methods since I figured they would be the safest, but I imagine this should work for the host at least. – cottonBallPaws Feb 17 '11 at 04:54
  • @littleFluffyKitty: You can make it work with other segments by applying the same logic to the following tokens: `://`, `:`, `@`, `/`, `?`, `&`, `#`. – Alix Axel Feb 17 '11 at 04:59
  • Thanks, that would do it. However, I updated my question (it didn't seem different enough to warrant a separate question), since it does look like I need a way to support/convert these characters. – cottonBallPaws Feb 17 '11 at 05:19