Repository navigation
Conversation
The generated flash-pf.bat and flash-boot.bat start with 'chcp 65001'
but were written as ISO-8859-1, so cmd decoded non-ASCII characters
as invalid UTF-8 and paths such as 'Téléchargements' reached adb
mangled ('failed to stat file'). Write batch files in the encoding of
their code page (UTF-8 for 65001, cpNNN for a custom code page, the
detected system code page otherwise), shell scripts as UTF-8, and let
the script editor read and save with the same encoding.
Fixes badabing2005#377
Owner
|
Really sorry I didn't notice this PR and worked on a fix. |
Author
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.
Fixes #377
Problem
The generated
flash-pf.batandflash-boot.batstart withchcp 65001, so cmd.exe decodes every following line as UTF-8, but the files were written withencoding="ISO-8859-1". Any non-ASCII character in a path (for example the French downloads folderTéléchargements) becomes an invalid UTF-8 byte, cmd turns it intoU+FFFD, and adb is given a path that does not exist:Change
runtime.get_batch_file_encoding(codepage): the encoding cmd will read the batch file with. UTF-8 for 65001,cpNNNfor a forced custom code page, the detected system code page when the script has nochcpline, and the previous ISO-8859-1 as the last fallback.pf_modules.py:flash-boot.batandflash-pf.batare written with that encoding, the.shfiles as UTF-8. When the user edits the script, it is read back with the same encoding.FileEditortakes an optionalencoding(default unchanged,ISO-8859-1), so editing the script before flashing does not re-encode it.Scripts with only ASCII content are byte-for-byte identical to before.
Testing
On Windows 11 (French locale), with a batch file generated the same way (
chcp 65001first line, run throughsubprocesswithshell=True) and a path under...\Téléchargements\:if exist "<path>"adb keygen "<path>"T�l�chargementsT�l�chargementsget_batch_file_encoding()checked for65001,1252,850, an unknown code page, a system code page of 850 or 65001 withoutchcp, and no code page at all.py_compilepasses on the three files. I did not run a full sideload with the patched build.