papr
papr

Reputation: 4777

Escaped unicode to unicode character in Cocoa

I get from a NSURLConnection a NSData object which I convert with

[[NSMutableString alloc] initWithData:[self urlData] encoding:NSUTF8StringEncoding]

to a NSMutableString. After some "revision" I display it in a NSTextField.
But when the response contains a more-than-utf8-string this is displayed:

problem http://b5.s3.p.quickshareit.com/files/screenshot_466c60a6beaa2b390.png

This "&#x27A1" should be one unicode character. The char after .ws/ seems to be an other problem which I would like to have solved. :)

It would be nice if there was a way without Carbon.

Upvotes: 0

Views: 1395

Answers (1)

Jesse Rusak
Jesse Rusak

Reputation: 57188

The "&#27a1" is an HTML/XML character reference, and I don't think it's caused by any encoding/decoding you're doing in the code you've shown. That is, that almost certainly appears that way in the source.

It looks like this page (via this page) has some sample code at the bottom that might be useful to convert those to the correct characters: both a version using NSXMLParser, and one using CFXMLCreateStringByUnescapingEntities.

Upvotes: 3

Related Questions