0

I'm trying to convert this :

NSString *encodedString = @"Les Profs (Comédie)" 

into another NSSting in unicode :

NSString *decodedString = @"Les Profs (Comédie)" 

I can't figure out how to do that easily...

Thanks in advance !

user7388
  • 1,741
  • 2
  • 19
  • 25
Nicolas Roy
  • 3,773
  • 5
  • 27
  • 42

2 Answers2

1

Your encoded string is containing html entities. You need to convert them to their unicode representation to get the required decoded string.

For conversion you can use following NSString extention
http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMNSString%2BHTML.h
http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMNSString%2BHTML.m

Here's how u will decode the string then

decodedStr = [encodedStr gtm_stringByUnescapingFromHTML];
ajonnet
  • 215
  • 2
  • 9
0

CFStringTransform is the Core Foundation function that gives you what you need.

uchuugaka
  • 12,679
  • 6
  • 37
  • 55