我有一个API,它将返回一个带有Unicode的String,例如:
您是否认为自己可以,或者您认为自己不能
–
是对的。
在上面的字符串中,–
为-
。
目前,我正在使用replacingOccurrences(of: "–", 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? p>