← Notes

Keep .bat Files ASCII-Only

1 min read#Windows#Debugging

A few Chinese comments added to a launcher script, and it crashed on double-click with a string of chopped-up command names.

The errors looked like 'p_code_sync' is not recognized: command names cut off in the middle. After chcp 65001, cmd parses a batch file by byte offsets; UTF-8 Chinese is multi-byte, so the commands after it get sliced into fragments and executed.

For a while I blamed line endings, because the exported file was CRLF. It turned out PowerShell’s Out-File had converted LF to CRLF; the .bat files in the repository had always been LF. In other words, the tool I used to inspect the file had changed it.

The final fix: restore the batch file to pure ASCII, keep a single line that calls Python, move all the logic into the Python script, and put a comment at the top saying the file must stay ASCII.

Written byShihao Qi