Is it possible to prevent textDocumentProxy from 'splitting' emoji?

只谈情不闲聊 提交于 2019-12-10 19:24:12

问题


I'm currently working on a third party keyboard for iOS and ran into a small annoyance with textDocumentProxy which I hoped y'all might be able to help me with.

So I have the two following variables defined which I am printing to the console -

selectedContextAfterInput = textDocumentProxy.documentContextAfterInput
selectedContextBeforeInput = textDocumentProxy.documentContextBeforeInput
print(selectedContextBeforeInput, selectedContextAfterInput)

and a UIPanGesture that adjustTextPositionByCharacterOffset() by 1 or -1 according to the direction of the pan. So while panning the cursor, the content before and after the cursor are being printed. This all works great except in cases where the string contains an emoji (i.e.😊🙃😬🙃). The emoji always ends up being split in undefined characters as show below (the grinning emoji is being split in this case)

Any help would be greatly appreciated. Thanks!

来源:https://stackoverflow.com/questions/34490249/is-it-possible-to-prevent-textdocumentproxy-from-splitting-emoji

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!