Skip to content

fix: truncating chapter titles using UTF-8 safe function#599

Merged
daveallie merged 7 commits intocrosspoint-reader:masterfrom
osteotek:fix-utf-safe-truncated-text
Feb 1, 2026
Merged

fix: truncating chapter titles using UTF-8 safe function#599
daveallie merged 7 commits intocrosspoint-reader:masterfrom
osteotek:fix-utf-safe-truncated-text

Conversation

@osteotek
Copy link
Member

@osteotek osteotek commented Jan 28, 2026

Summary

  • Truncating chapter titles using utf8 safe functions (Cyrillic titles were split mid codepoint)
  • refactoring of lib/Utf8

AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? < PARTIALLY >

@osteotek osteotek changed the title fix: truncating chapter titles with Utf8 safe fix: truncating chapter titles using UTF-8 safe function Jan 28, 2026
@osteotek osteotek requested a review from a team January 28, 2026 21:44
Copy link
Contributor

@lukestein lukestein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I'm getting an ellipsis (…) at the end of every chapter title, book title, filename, and author

See examples below. Truncation should only be if too long :)

image

image

daveallie
daveallie previously approved these changes Feb 1, 2026
@daveallie daveallie dismissed their stale review February 1, 2026 07:52

Pending @lukestein's feedback

Copilot AI review requested due to automatic review settings February 1, 2026 11:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a bug where chapter titles with multi-byte UTF-8 characters (such as Cyrillic) were being truncated incorrectly, causing character corruption. The fix involves refactoring UTF-8 utility functions from StringUtils to a dedicated Utf8 library and improving the text truncation logic to be UTF-8 safe.

Changes:

  • Moved utf8RemoveLastChar and utf8TruncateChars functions from StringUtils to the Utf8 library
  • Refactored GfxRenderer::truncatedText to use UTF-8 safe character removal instead of byte-based string operations
  • Updated all call sites to use the new function locations and improved truncation API

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/util/StringUtils.h Removed UTF-8 function declarations
src/util/StringUtils.cpp Removed UTF-8 function implementations
lib/Utf8/Utf8.h Added UTF-8 string manipulation function declarations
lib/Utf8/Utf8.cpp Added UTF-8 string manipulation function implementations
src/activities/home/HomeActivity.cpp Updated to call utf8RemoveLastChar from Utf8 library
src/activities/reader/TxtReaderActivity.cpp Replaced manual UTF-8-unsafe truncation loop with renderer.truncatedText
src/activities/reader/EpubReaderActivity.cpp Replaced manual UTF-8-unsafe truncation loop with renderer.truncatedText
lib/GfxRenderer/GfxRenderer.cpp Improved truncatedText implementation to be UTF-8 safe

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@daveallie daveallie merged commit b1dcb77 into crosspoint-reader:master Feb 1, 2026
7 checks passed
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 1, 2026
…reader#599)

## Summary

* Truncating chapter titles using utf8 safe functions (Cyrillic titles
were split mid codepoint)
* refactoring of lib/Utf8

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< PARTIALLY >**_
@lukestein
Copy link
Contributor

Running this and now seems to work great

jdk2pq added a commit to jdk2pq/crosspoint-reader that referenced this pull request Feb 3, 2026
* master:
  feat: Debugging monitor script (crosspoint-reader#555)
  fix: truncating chapter titles using UTF-8 safe function (crosspoint-reader#599)
  fix: don't wake up after USB connect (crosspoint-reader#644)
  Revert "fix: don't wake up after USB connect" (crosspoint-reader#643)
  fix: custom sleep not showing image at index 0 (crosspoint-reader#639)
  docs: Update USER_GUIDE.md (crosspoint-reader#625)
  fix: Hide button hints in landscape CW mode (crosspoint-reader#637)
  fix: WiFi error screen text clarifications (crosspoint-reader#612)
  fix: don't wake up after USB connect (crosspoint-reader#576)
  feat(ui): change popup logic (crosspoint-reader#442)
  feat: Add reading menu and delete cache function (crosspoint-reader#433)
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 3, 2026
…reader#599)

## Summary

* Truncating chapter titles using utf8 safe functions (Cyrillic titles
were split mid codepoint)
* refactoring of lib/Utf8

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< PARTIALLY >**_
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 3, 2026
…reader#599)

## Summary

* Truncating chapter titles using utf8 safe functions (Cyrillic titles
were split mid codepoint)
* refactoring of lib/Utf8

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< PARTIALLY >**_
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
…reader#599)

## Summary

* Truncating chapter titles using utf8 safe functions (Cyrillic titles
were split mid codepoint)
* refactoring of lib/Utf8

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< PARTIALLY >**_
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.

4 participants