Repository navigation
Commit 40f0b93
authored
[cross_file] fixed
`XFile.fromData(utf8.encode('😀')).readAsString()` hands back mojibake
The bytes branch uses `String.fromCharCodes` which just widens each byte into
its own UTF-16 code unit so anything outside ASCII comes out mangled and the
`encoding` parameter the method accepts never gets used at all. The file-backed
branch right below it passes `encoding` through fine, and web already does
`readAsBytes().then(encoding.decode)` so this is mostly just making native do
what web has been doing all along.
I made the method `async` while I was in there and that bit is deliberate
rather than cosmetic: `encoding.decode` can throw on bad input where
`fromCharCodes` never could and without `async` that would come out
synchronously instead of as a failed future, which isn't what you get from
either the web version or the `_file.readAsString` path.
fixes flutter#165120
AI usgae: I used antigravity (with gemini 3.7 flash)readAsString decoding in-memory bytes as UTF-16 (flutter#12479)1 parent 9f595f3 commit 40f0b93
4 files changed
Lines changed: 28 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
85 | 103 | | |
86 | 104 | | |
87 | 105 | | |
| |||
0 commit comments