How do I decode HTML entities in Swift?

后端 未结 23 1925
一生所求
一生所求 2020-11-22 01:47

I am pulling a JSON file from a site and one of the strings received is:

The Weeknd ‘King Of The Fall&         


        
23条回答
  •  無奈伤痛
    2020-11-22 02:45

    Have a look at HTMLString - a library written in Swift that allows your program to add and remove HTML entities in Strings

    For completeness, I copied the main features from the site:

    • Adds entities for ASCII and UTF-8/UTF-16 encodings
    • Removes more than 2100 named entities (like &)
    • Supports removing decimal and hexadecimal entities
    • Designed to support Swift Extended Grapheme Clusters (→ 100% emoji-proof)
    • Fully unit tested
    • Fast
    • Documented
    • Compatible with Objective-C

提交回复
热议问题