Skip to content

removingHTMLEntities will throw fatal error if decode JSONSerialization string #22

@tomcheung

Description

@tomcheung

I am using library with Xcode 10.2.1 (Swift 5), and found following code will throw Fatal error inside removeHTMLEntities

let jsonString = "{\"sepcialCharacter\": \"𝟸𝟺𝟶°\"}"
let json = try! JSONSerialization.jsonObject(with: jsonString.data(using: .utf8)!, options: []) as! [String:String]

let sepcialCharacter = json["sepcialCharacter"]!
sepcialCharacter.removingHTMLEntities

After investigation, seem this error may cause by NSString to swift String bridging with following code, not sure this is the bug in swift or the library itself

let nsSepcialCharacter = NSString("𝟸𝟺𝟶°")
let sepcialCharacter = nsSepcialCharacter as String
sepcialCharacter.removingHTMLEntities

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions