【发布时间】:2017-01-10 08:19:36
【问题描述】:
我收到一个包含NSTextAttachment 的NSAttributedString。我想删除那个附件,看起来它在字符串中表示为"\u{ef}"。打印此类字符串的 unicode 标量,"\u{ef}" 的 unicode 标量似乎也是 U\0000fffc。
我尝试过这样做:
noAttachmentsText = text.replacingOccurrences(of: "\u{ef}", with: "")
没有成功,所以我尝试比较 unicode 标量:
var scalars = Array(text.unicodeScalars)
for scalar in scalars {
// compare `scalar` to `U\0000fffc`
}
但我无法在比较中取得成功。 我怎么能这样做?
【问题讨论】:
-
@MikeAlter 不适合我
-
@AppsDev 你得到答案了吗?
标签: ios swift string unicode nsattributedstring