ai-coding-minesIndexGitHub

Emoji through a heredoc kills the script

Windows and PowerShell

Symptom

Python code written inside a shell heredoc, an emoji inside the Python, and the surrogate pair gets broken. The script dies.

Cause

The shell → Python hop is one more encoding boundary. Each boundary applies its own rules.

Why this bites non-ASCII users

Emoji sit outside the Basic Multilingual Plane and CJK needs multi-byte sequences; ASCII never does. A heredoc that passes ASCII text untouched can still corrupt these.

Fix

  1. Don't push it through a heredoc. Write it to a file, then run the file.
  2. Put the emoji character itself in the source, not an escape sequence.

Same reason we don't apply large patches via heredoc.