WWW problem : URL with blank symbol not functional on iOS

So, I tried making a WWW call to download some media on my web server.

It works fine for most of the files except when the url has a blank symbol e.g. the texture file name “hello world.png”
it will return “Bad URL” error message and not download anything. This only happens on iOS.

I also tried convert the url string using System.Uri.EscapeUriString() so the file name becomes “hello%20world.png”
but still no luck. :frowning:

Again, I have no problem on Android or Standalone.
Have anyone experienced the same problem before?

Have you tried Unity's EscapeUri procedure? http://unity3d.com/support/documentation/ScriptReference/WWW.EscapeURL.html

Also if you have a concrete problem, post the exact code you're using. If the system reports a bad URL you have for sure a bad URL. Have you printed your URL and checked how it looks like?

@Bunny83 : Got it working now, thanks for pointing that out, my bad. @guyt : I had to use System.Uri.EscapeUriString() in order to get the right friendly url, WWW.EscapeURL() somehow didn't do the job, maybe I wasn't using the right encoding?

1 Answer

1

So, to solve this, use System.Uri.EscapeUriString() to convert your url to a friendly one.

For example,

http://www.domain.com/hello world.mp3

will be converted to

http://www.domain.com/hello%20world.mp3

Note that, base on my experiment, I only need to do this on iOS.
Other platforms work with the url with blank symbol just fine, without having to convert.

However, it’s a good practice to always convert to friendly url string.
In case there’s any other character that’s not very friendly, I think. :slight_smile: