开发者

Is there an Objective C equivalent of the JavaScript method encode()?

NSString *searchString = @"Lyngbø";
NSLog("%@",[searchString stringByAddingPercentEscapeUsingEncoding:NSUTF8StringEncoding]);

This gives me : Lyng%C3%B8

<script type="text/javascr开发者_运维知识库ipt">
document.write(escape("Lyngbø"));
</script> 

This gives me : Lyngb%F8

The web search engine i am developing against doesnt understand the Objectiv C's way of encoding the string, and returns nothing when searching for words that contains either æ. ø or å


Charset difference. Instead of NSUTF8StringEncoding, use NSISOLatin1StringEncoding.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜