-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Substitute a replacement character for invalid UTF-16 text in a TextSpan #84887
Conversation
String text = 'Hello\uD83DWorld'; | ||
painter.text = TextSpan(text: text); | ||
painter.layout(); | ||
expect(painter.width, greaterThan(0.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be exactly 10.0, right? assuming default font size is 10 and font is Ahem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus points if you mention this somewhere in the API docs, maybe for Text, TextSpan, and TextPainter in particular. |
@jason-simmons in this line, As I understand you replace whole text with REPLACEMENT CHARACTER, Why whole text? We should replace only invalid characters You convert
|
Replacing individual characters is a lot of work, I really don't think we should do that given that the whole point is to fail. If you want to replace invalid characters, that's something to do in your app. |
@Hixie I understand, Assume I want to do it, There is many many string and |
You would have to provide a central place in your application where strings were sanitized, yes. But fundamentally, strings should be sanitized long before they reach |
Fixes #84693