Wednesday, April 27, 2022

AttributedString’s Codable Format

Ole Begemann:

The problem is that the character offsets that define the runs aren’t guaranteed to be stable. The definition of what constitutes a Character, i.e. a user-perceived character, or a Unicode grapheme cluster, can and does change in new Unicode versions.

[…]

The people on the Foundation team know all this, of course, and chose a better encoding format for Attributed String.

[…]

This is an array of runs, where each run consists of a text segment and a dictionary of formatting attributes. The important point is that the formatting attributes are directly associated with the text segments they belong to, not indirectly via brittle byte or character offsets.

Comments RSS · Twitter

Leave a Comment