How to prepare an NSURL from an NSString continaing international characters?

iphone, nsstring, nsurl

Solution

Yes there is, you need `-stringByAddingPercentEscapesUsingEncoding:` method:

[NSURL URLWithString:[string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

Problem

I have to access a web server using a `GET` with international characters (Hebrew in my case but could be anything). So I make an `NSString` just fine but ``` [NSURL URLWithString:urlString]; // returns nil. ``` I realize I probably have to convert the international characters to percent codes. Is there a built in method in Objective-c to do so?

Original source