在字符串中转换Unicode

时间:2017-03-16 03:41:03

标签: ios swift unicode

我有一个API,它将返回一个带有Unicode的String,例如:

  

您是否认为自己可以,或者您认为自己不能–是对的。

在上面的字符串中,&#8211-

目前,我正在使用replacingOccurrences(of: "&#8211", with: "\"", options: .regularExpression, range: nil)替换返回的String中的任何Unicode。但有一段时间我会得到一个我没有列入我的列表的Unicode。

在每个返回的String的末尾,我将使用+将字符串与Quote的作者组合。当我使用UnicodeScalar来投射字符串时,Xcode会给我binary operator + cannot be applied to operands of type unicode and string错误。

我觉得我的解决方案有效,但并不理想。有没有办法使用返回的String转换任何Unicode?

0 个答案:

没有答案