Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSString encoding from strings with chars like \u00f6 to UTF8

Tags:

cocoa

I get a NSStrings with characters like \u00f6. I can't find how to encode it to UTF8.

    NSString *resultString = [NSString stringWithContentsOfURL:wikiSearchURL usedEncoding:NSUTF8StringEncoding error:&err];

Thanks...

like image 203
Andreas Prang Avatar asked Aug 10 '26 12:08

Andreas Prang


1 Answers

I think you want to do this:

NSString *resultString = [NSString stringWithContentsOfURL:wikiSearchURL encoding:NSUTF8StringEncoding error:&err];

the usedEncoding: one will tell you what encoding it used when it parsed the URL, while the encoding: one will force it to use a particular encoding.

like image 73
Nate Thorn Avatar answered Aug 13 '26 01:08

Nate Thorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!