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

140 Views Asked by At

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!

0

There are 0 best solutions below