开发者

iPhone sending UTF-8 parameter in NSURL

i'm trying to search in google in a right to left language (hebrew arabic etc.开发者_StackOverflow社区.) and i've tried this

    NSURL *url = [NSURL URLWithString:@"http://www.google.com/search?q=امريكا"];
[[UIApplication sharedApplication] openURL:url];

but no use at all it ignore the url and skip the method as if it's empty .. while if i put english characters it's work just fine .. is there another way for those utf-8 character ?


Caveat: I don't do iPhone programming, and don't know how the operations/methods that you're using are supposed to work.

However, it seems like the URL is not being escaped.

The URL RFC is explicitly vague on character encoding within a URL ("This specification does not mandate any particular character encoding"). However, the URL is limited to ASCII letters, digits, and a small set of special characters. Everything else has to be encoded using percent-encoding.

Although the URL syntax doesn't specify a character-set encoding, a well-behaved server should accept UTF-8 characters, as long as they're percent-escaped. So the Hebrew character Sheva, unicode 05B0, should be stored in a URL as %D6%B0.

To diagnose, you'll need to look at the actual bytes going over the wire. Not sure how easy this will be to do with the iPhone, but a logging proxy such as Fiddler may help (yes, I know, it's a Windows app, but I'm sure there's an equivalent for the Mac).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜