Reputation: 51911
Why can't I append U+20000
or above UnicodeScalar
to 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).
It compiles, but causes runtime error: EXC_BAD_INSTRUCTION
.
While all of the following works:
str.extend(String(sipScalar))
str += String(sipScalar)
str.append(Character(sipScalar))
sipScalar.writeTo(&str)
Upvotes: 2
Views: 411