Changed interpretation of grapheme clusters

An additional big advancement is the way String interprets grapheme clusters. Conformity of Unicode 9 gives resolution to this.

The use of extended grapheme clusters for character values in Swift 4 means that concatenation and modification of Strings may cause no affect on a resulting String's character count.

For example, if you append a COMBINING ACUTE ACCENT (U+0301) to the end of the String initialized to "cafe", the resulting String will have a character count of 4, and the fourth character will be "e", not e':

var word = "cafe"print("total chars in \(word) is \(word.count)")

It prints "total chars in cafe is 4":

word += "\u{301}"    // COMBINING ACUTE ACCENT, U+0301print("totalchars in \(word) ...

Get Reactive Programming with Swift 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.