NSAttributedString and emojis: issue with positions and lengths
问题 I'm coloring some parts of a text coming from an API (think "@mention" as on Twitter) using NSAttributedString. The API gives me the text and an array of entities representing the parts of the text that are mentions (or links, tags, etc) which should be colored. But sometimes, the coloration is offset because of emojis. For example, with this text: "@ericd Some text. @apero" the API gives: [ { "text" : "ericd", "len" : 6, "pos" : 0 }, { "text" : "apero", "len" : 6, "pos" : 18 } ] which I