extension String {
var unicodeStr:String {
let tempStr1 = self.replacingOccurrences(of: "\\u", with: "\\U")
let tempStr2 = tempStr1.replacingOccurrences(of: "\"", with: "\\\"")
let tempStr3 = "\"".appending(tempStr2).appending("\"")
let tempData = tempStr3.data(using: String.Encoding.utf8)
var returnStr:String = ""
do {
returnStr = try PropertyListSerialization.propertyList(from: tempData!, options: [.mutableContainers], format: nil) as! String
} catch {
print(error)
}
return returnStr.replacingOccurrences(of: "\\r\\n", with: "\n")
}
}
网友评论