I have:
If a space is inserted after an emoji at the end of a line,
sometimes two question marks are sent instead of the emoji.
Actual result: The 11th emoji is converted to two question marks.
Expected result: There should be the emoji.

Device: Wiko Pulp 4G
Android version: 5.1.1
Signal version: 4.6.0
Reminds me a bit of this #5385
I don't have this issue on Signal 4.6.0 on Android 7.0.
I was able to reproduce this issue on Signal 4.6.1 on the Android Studio Emulator: Nexus_6_API_23.
After some investigation I think I understand what's happening, but I'm not sure how to fix it yet.
I inserted 13 emojis to fill up the first line, and the 14th would appear on the second line. When looking at the string representation it looked like there were two characters for every emoji character. So before I added a space after the 13th emoji character, the internal representation of the string was:
...\uD83D\uDE00\uD83D\uDE02
Where \uD83D\uDE00 was the 13th emoji at the end of the first line, and \uD83D\uDE02 was the 14th emoji at the beginning of the second line.
After inserting the space after the 13th emoji the internal string representation turned into this:
...\uD83D<SPACE_CHAR>\uDE00\uD83D\uDE02
So it looks like the space character gets inserted in between the two characters that represent the 13th emoji instead of in between the two emojis.
I also tested this with the same emojis and other single characters inserted at the end of the first line. I got similar broken results.
Would love to keep working on this. I'll keep investigating, but some suggestions would be appreciated.
This appears to be an Android framework bug on 6.x and below, as it is reproducible with a plain EditText in a new Android Studio project running on an API 23 emulator.
GitHub Issue Cleanup:
See #7598 for more information.
Most helpful comment
I was able to reproduce this issue on Signal 4.6.1 on the Android Studio Emulator: Nexus_6_API_23.
After some investigation I think I understand what's happening, but I'm not sure how to fix it yet.
I inserted 13 emojis to fill up the first line, and the 14th would appear on the second line. When looking at the string representation it looked like there were two characters for every emoji character. So before I added a space after the 13th emoji character, the internal representation of the string was:
Where
\uD83D\uDE00was the 13th emoji at the end of the first line, and\uD83D\uDE02was the 14th emoji at the beginning of the second line.After inserting the space after the 13th emoji the internal string representation turned into this:
So it looks like the space character gets inserted in between the two characters that represent the 13th emoji instead of in between the two emojis.
I also tested this with the same emojis and other single characters inserted at the end of the first line. I got similar broken results.
Would love to keep working on this. I'll keep investigating, but some suggestions would be appreciated.