Uh oh!
There was an error while loading. Please reload this page.
[cross_file] fixed readAsString decoding in-memory bytes as UTF-16 - #12479
Merged
auto-submit[bot] merged 2 commits intoAug 25, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the readAsString method in XFile to decode bytes using the provided encoding instead of String.fromCharCodes, fixing an issue where multi-byte characters were incorrectly decoded. It also adds corresponding unit tests for multi-byte characters, non-default encodings, and malformed data. The reviewer suggested avoiding the async keyword in readAsString to prevent unnecessary microtask delays and overhead, recommending the use of Future.sync instead.
Uh oh!
There was an error while loading. Please reload this page.
glitchflforce-pushed
the
fix-cross-file-utf8-read-as-string
branch
from
August 16, 2026 14:40
8c83c4b to
c49b2dcComparebparrishMines
commented
Aug 21, 2026
Contributor
@stuartmorgan-g or @tarrinneal for secondary review |
stuartmorgan-g
approved these changes
Aug 25, 2026
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 25, 2026
zijiehe-google-com pushed a commit
to zijiehe-google-com/flutter
that referenced
this pull request
Aug 25, 2026
…er#191734) flutter/packages@df2ba94...740f093 2026-08-25 srawlins@google.com [cupertino_ui] Remove unused parameters from constructors of generic classes. (flutter/packages#12457) 2026-08-25 srawlins@google.com [material_ui] Remove unused parameters from constructors of generic classes. (flutter/packages#12458) 2026-08-25 6655696+guidezpl@users.noreply.github.com Ignore shared code for iOS platform implementation of Google Maps plugin (flutter/packages#12529) 2026-08-25 136096126+glitchfl@users.noreply.github.com [cross_file] fixed `readAsString` decoding in-memory bytes as UTF-16 (flutter/packages#12479) 2026-08-25 lozhkovoi@gmail.com [cupertino_ui] Remove two items assert to allow CupertinoTabBar to have one tab (flutter/packages#12546) 2026-08-25 huahua8893@sina.cn [cupertino_ui] Fix covered sheet revealing root route through top gap (flutter/packages#12530) 2026-08-25 fluttergithubbot@gmail.com Sync release-go_router-18.0.0 to main (flutter/packages#12575) 2026-08-25 fluttergithubbot@gmail.com Sync release-material_ui-1.1.0 to main (flutter/packages#12577) 2026-08-25 fluttergithubbot@gmail.com Sync release-cupertino_ui-1.0.1 to main (flutter/packages#12576) 2026-08-24 41930132+hellohuanlin@users.noreply.github.com [quick_actions_ios]unskip XCUITests (flutter/packages#12436) 2026-08-24 karthimanikuttan001@gmail.com Fix RangeSlider thumb overlay remains visible after touch interaction ends (flutter/packages#12560) 2026-08-24 victor.orozco@cloudsufi.com [google_sign_in] Increase iOS coverage tests (flutter/packages#12484) 2026-08-24 269567208+reidbaker-agent@users.noreply.github.com [camera_android_camerax] Migrate from dart_skills_lint to skills_lint (flutter/packages#12543) 2026-08-24 74037732+developerashkan@users.noreply.github.com [go_router] Clarify onEnter/redirect ordering, add regression test (flutter/packages#12337) 2026-08-24 brunocorona.alcantar@gmail.com [material_ui] Port flutter/flutter flutter#185149 "Slider label clips the screen" (flutter/packages#12572) 2026-08-24 engine-flutter-autoroll@skia.org Roll Flutter from 65c9a8d to 9a82789 (17 revisions) (flutter/packages#12578) 2026-08-24 stuartmorgan@google.com [tool] Fix dart_test.yaml parsing (flutter/packages#12574) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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 freeto 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.
XFile.fromData(utf8.encode('😀')).readAsString()hands back mojibakeThe bytes branch uses
String.fromCharCodeswhich just widens each byte intoits own UTF-16 code unit so anything outside ASCII comes out mangled and the
encodingparameter the method accepts never gets used at all. The file-backedbranch right below it passes
encodingthrough fine, and web already doesreadAsBytes().then(encoding.decode)so this is mostly just making native dowhat web has been doing all along.
I made the method
asyncwhile I was in there and that bit is deliberaterather than cosmetic:
encoding.decodecan throw on bad input wherefromCharCodesnever could and withoutasyncthat would come outsynchronously instead of as a failed future, which isn't what you get from
either the web version or the
_file.readAsStringpath.fixesflutter/flutter#165120
AI usgae: I used antigravity (with gemini 3.7 flash)