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
.
精彩评论