swift版本:适合5.2以上
直接上代码:
func convertChina(uStr: String) -> String {
let tempValue1 = uStr.replacingOccurrences(of: "\\u", with: "\\U");
let tempValue2 = tempValue1.replacingOccurrences(of: "\"", with: "\\\"");
let tempValue3 = "\"".appending(tempValue2).appending("\"");
let tempData = tempValue3.data(using: .utf8)
let resultString = try? PropertyListSerialization.propertyList(from:
tempData!, options:
PropertyListSerialization.ReadOptions.mutableContainersAndLeaves,
format: nil) as? String
return resultString ?? uStr
}