RegeributedTextView icon indicating copy to clipboard operation
RegeributedTextView copied to clipboard

fix: emoji annoys string.count

Open sakmt opened this issue 7 years ago • 0 comments

Sorry, this pull request is Japanese only!!

問題

文字列に絵文字が含まれていた場合、絵文字の数だけNSRangeの末尾がカットされているようです。

// addAttribute(.hashTag, attribute: .textColor(.red)) で赤くなる文字
"hoge #fuga" // => #fuga
"hoge🍣 #fuga" // => #fug
"hoge🍣🍶 #fuga" // => #fu

解決策

UTF16に変換してcountすることで解決すると思われます。

sakmt avatar Sep 18 '18 06:09 sakmt