Skip to content

Fix multi-byte character handling in chat#4

Merged
anf3is merged 2 commits intoreactivedrop_betafrom
fix/chat-cut-utf8
May 6, 2026
Merged

Fix multi-byte character handling in chat#4
anf3is merged 2 commits intoreactivedrop_betafrom
fix/chat-cut-utf8

Conversation

@anf3is
Copy link
Copy Markdown
Owner

@anf3is anf3is commented Apr 28, 2026

Problems

  1. Message validation may truncate input in the middle of a multi-byte utf-8 sequence, producing invalid text.
  2. Chat input operates on utf-16 wchar characters, but message sending uses utf-8 char.
  3. Chat input doesn’t represent what will be sent over, because non-Latin letters in most languages are typically multi-byte characters that take up only a single wchar and 2–3 char.

Goals

  • Fix truncation in message validation
  • Fix char limit calculation in chat box input
  • Do not fix truncation splitting utf-8 graphemes

Test strings

Details

Bytes

  • numbers 123… represent 110 + n byte position (counting from 1)
  • | represent string cutoff
  • x represent utf-8 code point's byte
_128_chars______________________________________________________________________________________________________7|8__ok_12345678
ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ_____7|8____ok_12345678
ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ____6x|x___nok_123456ø
ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ___5xx|x___nok_12345Ⓐ
ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ__4xxx|_____ok_1234Ⓐ

Chars

128 characters ("Ⓐ"*41+"Ⓑ"*(126-41)+"78"). 300+ bytes.

ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷⒷ78

Examples

Details

Before

SuperCake: _128_chars______________________________________________________________________________________________________7|8__ok_1234567
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ_____7|8____ok_1234567
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ____6x|x___nok_123456�
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ___5xx|x___nok_12345�
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ__4xxx|_____ok_1234Ⓐ
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒷ�溰p䷗ট溰p�

After

SuperCake: _128_chars______________________________________________________________________________________________________7|8__ok_1234567
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ_____7|8____ok_1234567
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ____6x|x___nok_123456
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ___5xx|x___nok_12345
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶ__4xxx|_____ok_1234Ⓐ
SuperCake: ⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒶⒷ7

@anf3is anf3is force-pushed the fix/chat-cut-utf8 branch 3 times, most recently from fd6c2a5 to cafff58 Compare April 28, 2026 19:22
@anf3is anf3is changed the title Fix/chat cut utf8 Fix chat special char bad cutoff Apr 28, 2026
@anf3is anf3is self-assigned this Apr 28, 2026
@anf3is anf3is force-pushed the fix/chat-cut-utf8 branch 5 times, most recently from ec5b2af to db50376 Compare April 29, 2026 11:08
@anf3is anf3is force-pushed the fix/chat-cut-utf8 branch 11 times, most recently from fb37bb7 to c396e2c Compare April 30, 2026 14:19
@anf3is anf3is changed the title Fix chat special char bad cutoff Fix chat input limit miscalculation for multi-byte characters Apr 30, 2026
@anf3is anf3is changed the title Fix chat input limit miscalculation for multi-byte characters Fix multi-byte character handling in chat input Apr 30, 2026
@anf3is anf3is changed the title Fix multi-byte character handling in chat input Fix multi-byte character handling in chat Apr 30, 2026
@anf3is anf3is force-pushed the fix/chat-cut-utf8 branch from c396e2c to 05d42c7 Compare April 30, 2026 14:46
Because of the `Send` method, max char limit should be based on utf-8
byte count, not utf-16 chars.
@anf3is anf3is force-pushed the fix/chat-cut-utf8 branch from 05d42c7 to cd6a1a8 Compare April 30, 2026 20:01
@anf3is
Copy link
Copy Markdown
Owner Author

anf3is commented Apr 30, 2026

Why would github tag issue in main repo 😕
I just added #855

@anf3is anf3is force-pushed the reactivedrop_beta branch from ea5c68f to 78ca92a Compare May 2, 2026 18:09
@anf3is anf3is merged commit 0467be2 into reactivedrop_beta May 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant