Skip to content

Add support for a GraphemeString utility class#191

Draft
rkeene wants to merge 5 commits intomainfrom
feature/utils-grapheme-string
Draft

Add support for a GraphemeString utility class#191
rkeene wants to merge 5 commits intomainfrom
feature/utils-grapheme-string

Conversation

@rkeene
Copy link
Member

@rkeene rkeene commented Feb 20, 2026

This change provides support for a GraphemeString utility class for handling short user strings that they tend to think of as having a length equivalent to their visible length.

@rkeene rkeene requested review from Copilot and ezraripps February 20, 2026 05:50
@rkeene rkeene self-assigned this Feb 20, 2026
@rkeene rkeene added the enhancement New feature or request label Feb 20, 2026
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 PR introduces a new GraphemeString utility class that provides grapheme cluster-aware string operations for handling user-facing text. This is particularly important for correctly measuring the visual length of strings containing emoji, accented characters, and other complex Unicode sequences.

Changes:

  • Adds GraphemeString class in src/lib/utils/grapheme-string.ts with comprehensive String API compatibility
  • Provides grapheme-aware alternatives to standard string methods (e.g., sliceGrapheme, concatGrapheme, trimGrapheme)
  • Includes extensive test suite covering emoji, normalization, international scripts, and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/lib/utils/grapheme-string.ts New utility class implementing grapheme cluster-aware string operations using Intl.Segmenter
src/lib/utils/grapheme-string.test.ts Comprehensive test suite with ~1900 lines covering constructor, string methods, Unicode normalization, emoji, international scripts, and edge cases

@rkeene rkeene marked this pull request as ready for review February 20, 2026 06:12
@rkeene rkeene requested a review from Srayman February 20, 2026 06:23
@rkeene rkeene marked this pull request as draft February 24, 2026 20:11
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants