0

I needed to encode character to &#xxxxx; format such as Chinese Characters, I would like to convert a chinese character to a '&#xxxxx;' format. I want: a Character -> "&#20013".....

anyone could help me with?? many many many thanks!!

1 Answers1

0

You can try using this NSString+HTML category by Michael Waterfall.

You'll need to:

  1. Add NSString+HTML.h, NSString+HTML.m, GTMNSString+HTML.h, and GTMNSString+HTML.m into your project
  2. (If you're not using ARC, skip this step) Because NSString+HTML isn't ARC-compatible, you'll need to go to the Build Phases under your Target, find the .m files and add -fno-objc-arc under their Compiler Flags
  3. #import "NSString+HTML.h"
  4. Use as so:

    [chineseString stringByEncodingHTMLEntities]
    
Community
  • 1
  • 1
Yazid
  • 970
  • 7
  • 14