HTML character decoding in Objective-C / Cocoa Touch

后端 未结 13 1997
我寻月下人不归
我寻月下人不归 2020-11-22 10:24

First of all, I found this: Objective C HTML escape/unescape, but it doesn\'t work for me.

My encoded characters (come from a RSS feed, btw) look like this: &a

相关标签:
13条回答
  • 2020-11-22 11:17

    Nobody seems to mention one of the simplest options: Google Toolbox for Mac
    (Despite the name, this works on iOS too.)

    https://github.com/google/google-toolbox-for-mac/blob/master/Foundation/GTMNSString%2BHTML.h

    /// Get a string where internal characters that are escaped for HTML are unescaped 
    //
    ///  For example, '&' becomes '&'
    ///  Handles   and 2 cases as well
    ///
    //  Returns:
    //    Autoreleased NSString
    //
    - (NSString *)gtm_stringByUnescapingFromHTML;
    

    And I had to include only three files in the project: header, implementation and GTMDefines.h.

    0 讨论(0)
提交回复
热议问题