ai-coding-minesIndexGitHub

Encoding changes at every tool boundary (the general case)

Windows and PowerShell

Every time text crosses a tool boundary, the encoding rules change. Neither side raises an error. Only the output comes out quietly broken.

BoundarySymptom
File → Get-ContentUTF-8 read as 949, written back, non-ASCII self-destructs
File → powershell.exe parserNo BOM, source read as ANSI, literals garbled
Shell heredoc → PythonEmoji surrogate pairs broken
PS → native exe argumentsDouble quotes re-parsed, arguments split
Code → env var keyNon-ASCII key ignored or mangled

Principles

  1. Cross boundaries with files. Don't shove bulk text through inline strings.
  2. Don't leave non-ASCII as literals. If you can't guarantee the code page the source will be read in, decode at runtime or fall back to Latin letters.
  3. Print once after the hop. Look at the actual bytes right after they cross the boundary.