Open ltlnx opened 3 years ago
@ltlnx It's because the Emoji support in Guileless Bopomofo is implemented by a dirty hack. To give a fully, well designed implementation, I have to spend time to modify the internal design of libchewing, it's a big challenge for me, frankly speaking I can't promise you a milestone or schedule, but I knew the issue and want to solve it.
Ahh I see, take your time!
This issue is also related to android.widget.TextView#getOffsetForPosition which is have weird difficulty to locate character offset correctly, if there is a string like the example provided which has Emoji(s).
Anyway, to solve this issue, I have to consider the nature of Emoji, that is encoded as variant bytes.
As an example like the following screenshot shown, the "貓咪🐈" pre-edit buffer string is encoded as UTF-8 as 0xe8, 0xb2, 0x93("貓"), 0xe5, 0x92, 0xaa("咪"), 0xf0, 0x9f, 0x90, 0x88("🐈"). We can find that each character has different size of bytes.
Perhaps I should consider to re-implement the whole pre-edit buffer cursor detection logic... at least the android.widget.TextView#getOffsetForPosition one.
ref:
When there are Emojis and Chinese mixed in the choosing area, the word-choosing behavior is strange. As in the attachments.