BluE_MoOn
BluE_MoOn

Reputation: 103

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/javascript">
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 å

Upvotes: 3

Views: 282

Answers (1)

Seva Alekseyev
Seva Alekseyev

Reputation: 61388

Charset difference. Instead of NSUTF8StringEncoding, use NSISOLatin1StringEncoding.

Upvotes: 6

Related Questions