Skip to content

Fix description truncation for emoji and wide characters#4080

Draft
thaafox wants to merge 1 commit intoGothenburgBitFactory:developfrom
thaafox:fix/emoji-description-truncation
Draft

Fix description truncation for emoji and wide characters#4080
thaafox wants to merge 1 commit intoGothenburgBitFactory:developfrom
thaafox:fix/emoji-description-truncation

Conversation

@thaafox
Copy link

@thaafox thaafox commented Mar 24, 2026

Summary

Replace byte-based substr() with utf8_truncate_to_width() in ColDescription truncated/truncated_count render styles.

Fixes #2333

Depends on GothenburgBitFactory/libshared#114

Problem

Truncating descriptions containing emoji or other multi-byte UTF-8 characters produces garbled output because substr() cuts at byte boundaries, not character boundaries. This affects all platforms.

Screenshot

emoji-demo

Changes

  • ColDescription.cpp: 2 lines changed — description.substr()utf8_truncate_to_width(description, ...)

Test plan

  • task add "📄 Emoji renders correctly" displays properly
  • Long descriptions with emoji truncate with clean ... suffix
  • ZWJ sequences (👨‍💻) and symbols (★⚡→●) render correctly
  • No corrupted bytes in truncated output

The "truncated" and "truncated_count" description styles use
std::string::substr() with a byte offset derived from display width,
which splits multi-byte UTF-8 sequences (emoji, CJK characters)
mid-character, producing garbled output.

Replace with utf8_truncate_to_width() which iterates by codepoint
and respects character boundaries.

Fixes GothenburgBitFactory#2333
@djmitche djmitche marked this pull request as draft March 24, 2026 23:42
@djmitche
Copy link
Collaborator

This looks like an AI-generated PR so I won't comment extensively, but please mark this as ready for review when it is ready.

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.

Update Unicode character width determination to support newer versions of Unicode

2 participants