I have a page with JS in my UIWebview which is to send some non-english text to my Obj C code. When I do a NSlog of what I receive in my Obj C code I get garbled output. Can someone see what is wrong here:
JS Code:
window.open("http://nothing.com?ST=nǐ",null);
Obj C code:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog([[request URL] absoluteString]);
return YES;
}
Console output:
You use the string as format of
NSLog(). Withyou will get the expected output.
Detailed explanation: The UTF-8 sequence for ǐ is C7 90. The contents of
[[request URL] absoluteString]inshouldStartLoadWithRequestisIf you use this as format string, the “%C” will be replaced by a random character.
To get rid of the percent escapes, use