为什么我无法将U+20000
或UnicodeScalar
追加到String
?
var str = ""
let bmpScalar = UnicodeScalar(0x04e19) // 丙
let smpScalar = UnicodeScalar(0x1F600) //
let sipScalar = UnicodeScalar(0x20011) //
str.append(bmpScalar) // "丙"
str.append(smpScalar) // "丙"
str.append(sipScalar) // < [!] Exection was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
它编译,但会导致运行时错误:EXC_BAD_INSTRUCTION
。
虽然以下所有方法都有效:
str.extend(String(sipScalar))
str += String(sipScalar)
str.append(Character(sipScalar))
sipScalar.writeTo(&str)
答案 0 :(得分:1)
此问题已在版本6.3(6D520o)中修复