fix(desktop): derive avatar initials by character, not code unit - #5992
Open
Chessing234 wants to merge 2 commits into
Open
fix(desktop): derive avatar initials by character, not code unit#5992Chessing234 wants to merge 2 commits into
Chessing234 wants to merge 2 commits into
Conversation
`getInitials` took `part[0]`, a UTF-16 code unit. A name whose first letter lives outside the Basic Multilingual Plane is a surrogate pair, so that returned half of one — not a character. CJK Extension B appears in ordinary Chinese and Japanese given names, and every avatar for such a person rendered `�`. Iterate code points, and take two of them before joining rather than slicing two code units off the result, so the second initial cannot be halved either. Signed-off-by: Taksh <takshkothari09@gmail.com>
Combining marks are neither `\p{L}` nor `\p{N}`, so `getInitials` replaced
them with a separator and cut words apart from the inside. "अनिल कुमार" split
at the vowel sign into "अन" and "ल", producing "अल" — two letters from the
middle of the first name, with the surname never reached. A one-word name
like "नमस्ते" produced two initials where there is one word to initial.
Devanagari, Burmese, Thai and Khmer names take marks in ordinary spelling.
Keep `\p{M}` alongside letters and numbers. Punctuation is still stripped, so
"B (relay)" still gives "BR".
Signed-off-by: Taksh <takshkothari09@gmail.com>
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Found by probing
getInitialswith non-Latin names; no issue filed. It feeds every avatar fallback in the app —UserAvatar,ProfileAvatar,IdentityInitialsAvatar,CommunityRail.Two separate bugs, one commit each.
Half a surrogate pair. The function took
part[0], a UTF-16 code unit. A name whose first letter lives outside the Basic Multilingual Plane is a surrogate pair, so that returned half of one — not a character:CJK Extension B appears in ordinary Chinese and Japanese given names, so every avatar for such a person rendered
�. Now iterating code points, and taking two of them before joining rather than slicing two code units off the result, so the second initial can't be halved either.A word cut in half at a combining mark. Marks are neither
\p{L}nor\p{N}, so they were replaced with a separator — cutting words apart from the inside:अनिल कुमारअलअकनमस्तेनतनမောင်မောင်မငမ"अनिल कुमार" split at the vowel sign into "अन" and "ल", so both initials came from the middle of the first name and the surname was never reached; a one-word name produced two initials where there is one word to initial. Devanagari, Burmese, Thai and Khmer names take marks in ordinary spelling.
\p{M}is now kept alongside letters and numbers — punctuation is still stripped, and the existing"B (relay)" → "BR"case is pinned by a test in both commits.Verified locally at this head:
pnpm test— 4961 passed, 0 failed (4954 before, plus the 7 new)pnpm check— clean; its 2 warnings and 2 infos are pre-existing and identical onmainpnpm build— succeededNote: I'm an outside contributor, so the workflow runs here sit at
action_requireduntil a maintainer approves them; only the DCO check reports on its own.