os.dart: Switch the codepage to UTF-8 when calling where.exe#186580
os.dart: Switch the codepage to UTF-8 when calling where.exe#186580CrossVR wants to merge 2 commits into
Conversation
Currently the output of `where` on Windows is decoded using the system default code page queried through `GetACP()`. However, since `where` expects to be run from a console it uses the console output code page. On a standard windows configuration these two code pages are different and one cannot be safely interpreted as the other. For example, in a U.S. locale this would cause the console code page 437 to be interpreted as code page 1252. By prefixing the `where` command with `chcp 65001` we can ensure UTF-8 encoding is being used resolving the conflict and forcing an encoding that is much safer for filesystem paths.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the Windows executable search logic in packages/flutter_tools/lib/src/base/os.dart to set the active code page to UTF-8 before running the where command. A review comment points out that the use of the && operator requires setting runInShell: true to avoid execution failure and recommends redirecting the chcp output to nul to prevent it from interfering with the parsed results.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Currently the output of
whereon Windows is decoded using the system default code page queried throughGetACP(). However, sincewhereexpects to be run from a console it uses the console output code page.On a standard windows configuration these two code pages are different and one cannot be safely interpreted as the other. For example, in a U.S. locale this would cause the console code page 437 to be interpreted as code page 1252.
By prefixing the
wherecommand withchcp 65001we can ensure UTF-8 encoding is being used resolving the conflict and forcing an encoding that is much safer for filesystem paths.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.