- Reactive Programming with Swift 4
- Navdeep Singh
- 191字
- 2021-06-24 18:57:59
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+0301
print("totalchars in \(word) is \(word.count)")
It prints "total chars in cafe? is 4", whereas the count would increase by 1 to reflect 5 as a result of print statement earlier.
Similar to Dictionaries, the total number of modifications made to String API can be summed up by the following image:

- Learning Chef
- Mastering Natural Language Processing with Python
- 碼上行動:零基礎學會Python編程(ChatGPT版)
- 嚴密系統設計:方法、趨勢與挑戰
- Python編程實戰
- Mastering Drupal 8 Views
- Python算法詳解
- 玩轉.NET Micro Framework移植:基于STM32F10x處理器
- UML基礎與Rose建模實用教程(第三版)
- Koa與Node.js開發實戰
- Node.js Web Development
- C語言從入門到精通(第4版)
- 給產品經理講技術
- Learning ClojureScript
- Learning ArcGIS Geodatabases