将U + 20000或以上UnicodeScalar附加到String

时间:2014-12-05 09:32:47

标签: swift unicode

为什么我无法将U+20000UnicodeScalar追加到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)

1 个答案:

答案 0 :(得分:1)

此问题已在版本6.3(6D520o)中修复