fix: Unicode Text length Calculation#16219
Open
vineethkuttan wants to merge 3 commits into
Open
Conversation
| for (auto fragment : m_attributedStringBox.getValue().getFragments()) { | ||
| if (textPosition < fragment.string.length()) { | ||
| uint32_t utf16Length = | ||
| static_cast<uint32_t>(::Microsoft::Common::Unicode::Utf8ToUtf16Length(fragment.string)); |
Contributor
There was a problem hiding this comment.
This change introduces Utf8ToUtf16Length, which can throw on conversion failure/overflow. It is now called from methods marked noexcept (eventEmitterAtPoint, IsTextSelectableAtPoint, RenderText, GetTextLayout). Any throw here would trigger terminate. Could we either make Utf8ToUtf16Length non-throwing for these call paths, or catch/fallback at callsites to avoid process termination?
Performance Test ResultsBranch: ✅ Passed161 scenario(s) across 28 suite(s) — no regressionsSectionList
FlatList
TouchableOpacity
ScrollView
TouchableHighlight
Pressable
Modal
Image
ActivityIndicator
Switch
Button
TextInput
View
Text
SectionList.native-perf-test.ts
FlatList.native-perf-test.ts
TouchableHighlight.native-perf-test.ts
TouchableOpacity.native-perf-test.ts
Pressable.native-perf-test.ts
ScrollView.native-perf-test.ts
ActivityIndicator.native-perf-test.ts
TextInput.native-perf-test.ts
Switch.native-perf-test.ts
Button.native-perf-test.ts
Modal.native-perf-test.ts
Image.native-perf-test.ts
View.native-perf-test.ts
Text.native-perf-test.ts
|
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.
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