Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(media): truncate media label with consideration of full-width characters #505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sakarie9
Copy link

Previously, all characters were treated as 1 unit wide, which caused incorrect truncation for certain characters, such as CJK characters. This resulted in media labels being longer than expected when compared to ASCII characters.

For instance, when the "Media - Truncation Size" is set to 30, the truncation works correctly for alphabetic characters, displaying up to 30 characters. However, for CJK characters, each character was counted as 1 unit, causing the truncation to display approximately twice the width compared to 30 alphabetic characters.

This commit introduces a Regex solution to count full-width characters as 2 units in length. While this approach may not cover every possible full-width character, it should be sufficient for most common scenarios.

@Jas-SinghFSU Jas-SinghFSU self-assigned this Nov 17, 2024
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.

3 participants