Faced a problem when, due to the use of emoji, the cursor position shifts by one position. For example, if you write "text", then if the cursor is at the end of a word, then its position will be 5, but if you immediately put a smiley after this word, then the cursor behind the smiley will already have position 7, although the logic would be 6.
I understand that this is due to the fact that more bits are used for emoji and because of this, the position is shifted. But how then to find out the real position of the cursor?
If you work with simple text, then I just subtracted 1 from the position of the cursor and received the index of the character after which the cursor stands (well, except for the case when the cursor is at the very beginning of the text and its position is 0). But if you use emoji, this technique does not work.