hiroshiyui / GuilelessBopomofo

Guileless Bopomofo(樸實注音鍵盤)- A Bopomofo(注音符號)software keyboard (aka input method editor) on Android, which is utilizing libchewing for intelligent phonetic processing.
Other
94 stars 6 forks source link

Strange behavior when choosing characters #11

Open ltlnx opened 3 years ago

ltlnx commented 3 years ago

When there are Emojis and Chinese mixed in the choosing area, the word-choosing behavior is strange. As in the attachments. Screenshot_20210530-121240_Bromite Screenshot_20210530-121247_Bromite Screenshot_20210530-121255_Bromite

hiroshiyui commented 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.

ltlnx commented 3 years ago

Ahh I see, take your time!

hiroshiyui commented 3 years ago

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.

hiroshiyui commented 3 years ago

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.

device-2021-06-11-180522

Perhaps I should consider to re-implement the whole pre-edit buffer cursor detection logic... at least the android.widget.TextView#getOffsetForPosition one.

ref: