调用-dic.unicodeDescription
extension Array{
var unicodeDescription : String {
return self.description.stringByReplaceUnicode
}
}
extension Dictionary {
var unicodeDescription : String{
return self.description.stringByReplaceUnicode
}
}
extension String {
var unicodeDescription : String{
return self.stringByReplaceUnicode
}
var stringByReplaceUnicode : String{
let str1 = self.replacingOccurrences(of: "\\u", with: "\\U")
let str2 = str1.replacingOccurrences(of: "\"", with: "\\\"")
let str3 = "\"".appending(str2).appending("\"")
let data = str3.data(using: String.Encoding.utf8)
var returnStr:String = ""
do {
returnStr = try PropertyListSerialization.propertyList(from: data!, options: [.mutableContainers], format: nil) as! String
} catch {
print(error)
}
return returnStr.replacingOccurrences(of: "\\n", with: "\n")
}
}