Using Swift to unescape unicode characters, ie \u1234

前端 未结 3 1005
耶瑟儿~
耶瑟儿~ 2020-12-01 22:56

I have problems with special characters when using JSON in xcode 6 with swift

I found these codes in Cocoa/objective C to solve some problems converting accent but c

3条回答
  •  一个人的身影
    2020-12-01 23:36

    Swift 4 String extension

    extension String {
        var unescapingUnicodeCharacters: String {       
            let mutableString = NSMutableString(string: self)
            CFStringTransform(mutableString, nil, "Any-Hex/Java" as NSString, true)
    
            return mutableString as String
        }
    }
    

提交回复
热议问题