… and used stringByAddingPercentEscapesUsingEncoding from Cocoa.
The decodeURIComponent not unescape if you’re using unicode in JavaScript… article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.
If you're communicating between Cocoa and JavaScript in your iPhone application (I guess we call 'em hybrid apps these days 'cos it sounds cool), you may have to pass unicode content back and forth (e.g., as the argument to a function call in JavaScript).
On the Cocoa side of things, it's as easy as:
NSString *js = [NSString stringWithFormat:@"myLovelyJavaScriptFunction(\"%@\");", [someContent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[myBeautifulWebView stringByEvaluatingJavaScriptFromString:js];
On the JavaScript side, you may be tempted to use unescape on the argument. Don't or you won't get any of the Unicode goodness in your string (and we all know that healthy strings needs lots and lots of Unicode!) Instead use decodeURIComponent like this:
function myLovelyJavaScriptFunction(myAwesomeParameter) { var myRidiculouslyFabUnescapedContent = decodeURIComponent(myAwesomeParameter); ("Unicode radness follows: " + myRidiculouslyFabUnescapedContent); }
Hope this helps someone else out there :)
The decodeURIComponent not unescape if you’re using unicode in JavaScript… article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

As a general rule of thumb, in JavaScript, always use the xxxURIComponent methods over the escape and unescape. Simple example – the plus symbol isn’t escaped using escape (so I’m not sure what the reason behind the name was!).