1

I encountered this weird problem in Swift:

let str = ""             // US flag + German flag
print(str.characters.count) // 1, why???

But if I add a space between the two flags, str.characters.count return 3.

I know how flags are encoded (2 REGIONAL INDICATOR SYMBOL LETTERS per flag). Is this correct behavior in the Unicode standard or a Swift bug?

Jenny
  • 2,041
  • 13
  • 15
  • 2
    This is going to change if Unicode 9 is (hopefully) implementing in Swift 4: http://stackoverflow.com/questions/26862282/swift-countelements-return-incorrect-value-when-count-flag-emoji#comment66888231_26863367. – Martin R Apr 28 '17 at 12:09
  • Also related: [How to know if two emojis will be displayed as one emoji?](http://stackoverflow.com/questions/39104152/how-to-know-if-two-emojis-will-be-displayed-as-one-emoji) – Martin R Apr 28 '17 at 12:13

0 Answers0