0

I have an NSString that has the following value:

   "What#39;s up fellas!"

Is there a simple way to turn HTML char codes like #39; (equivalent to ') into an apostrophe etc?

Sheehan Alam
  • 57,155
  • 123
  • 348
  • 546

3 Answers3

3

check GTMNSString+HTML.h out :) It's a part of the Google Toolbox, an extension for iOS development. taken from this question

Community
  • 1
  • 1
Zaky German
  • 13,986
  • 4
  • 22
  • 30
0

Try this one, it works:

#import "NSString+HTML.h"

- (void)viewDidLoad
{
    [super viewDidLoad];

     NSString *r = @"This is a '\'";
     NSString *s = @"This is a &ltHTML-Tag&gt";

     NSString *encodedstring =  [r kv_encodeHTMLCharacterEntities];

     NSString *decodedstring =  [s kv_decodeHTMLCharacterEntities];

}
Rostyslav Dzinko
  • 36,138
  • 5
  • 44
  • 59
Phil
  • 71
  • 1
  • 1
-2

NSString has an UTF8 encode-decode function:

- (id)initWithUTF8String:(const char *)bytes
+ (id)stringWithUTF8String:(const char *)bytes
- (const char *)UTF8String

See the Class Reference here

Stefan Ticu
  • 2,063
  • 1
  • 12
  • 21