[0.81] fix: Unicode Text length Calculation#16185
Conversation
There was a problem hiding this comment.
Looks good — correctly fixes the UTF-8 vs UTF-16 length mismatch for DirectWrite text ranges. One suggestion for a follow-up optimization:
Minor optimization: Each Utf8ToUtf16(fragment.string).length() allocates a temporary std::wstring just to get the length. Would it be worth adding a Utf8ToUtf16Length() helper to vnext/Common/unicode.h that calls MultiByteToWideChar with a null output buffer? That would avoid the allocation entirely — could matter in hot paths like RenderText and hit-testing loops.
Not blocking — the fix is correct as-is.
Will add this while forward porting to main and other stable versions. And for 0.81 will raise the separate PR for this. |
Description
The length of text that is being rendered is not calculated for Unicode characters, this change will fix it
Type of Change
Why
Text Highlight for Unicode is not working
Screenshots
Testing
Tested in Playground
Changelog
Should this change be included in the release notes: yes
(fix: Unicode Text length Calculation)
Microsoft Reviewers: Open in CodeFlow