rintaro
rintaro

Reputation: 51911

Append U+20000 or above UnicodeScalar to String

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

Answers (1)

rintaro
rintaro

Reputation: 51911

This issue has been fixed in Version 6.3 (6D520o)

Upvotes: 1

Related Questions