Fix handling of emojis with ZWJ sequences in profile initials #5023
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix handling of emojis with ZWJ sequences in profile initials
Pull Request Type
Description
At the moment we use
Array.from
to get the first character in the profile name to use as the initial in the bubble, while that correctly handles basic emojis, it doesn't handle flag or family emojis as well as ones with skin tone modifiers very well, splitting them up into their individual characters instead of keeping them as one unit. This pull request fixes that by usingIntl.Segmenter
instead, which does locale aware splitting and also splits by user-perceived character, so it keeps the emojis intact.Screenshots
Beforehand
Afterwards
Testing
Test profile names with some complex emojis in them:
https://emojipedia.org/flags
https://emojipedia.org/emoji-zwj-sequence
https://emojipedia.org/people#families-couples
Please note that Windows doesn't show flags correctly, that's not an issue with FreeTube but an issue with Windows.
Desktop