Fix cp1252 UnicodeEncodeError from emoji prints on Windows#203
Open
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
Open
Fix cp1252 UnicodeEncodeError from emoji prints on Windows#203d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
d123d wants to merge 1 commit intoJuliusBrussee:mainfrom
Conversation
…or on Windows
Prior art: issue is mentioned in caveman's own CLAUDE.md guidance about
cross-platform hooks. Same class of bug hits the Python compress scripts.
Symptom: on Windows consoles with cp1252 encoding (default for many installs),
print statements containing emoji (\u274c, \u26a0, \u2705) raise:
UnicodeEncodeError: 'charmap' codec can't encode character '\u274c'
This obscures real error messages (e.g. in cli.py:68 catch-all handler),
making compress failures hard to debug on Windows.
Scope:
- cli.py: 4 sites (file-not-found, not-a-file, compression-failed, catch-all)
- compress.py: 3 sites (backup-exists, validation-failed, retries-exhausted)
- benchmark.py: 4 sites (pass/fail markers, not-found errors)
Replacements:
\u274c -> [ERROR]
\u26a0 -> [WARNING]
\u2705 -> [OK]
No behavior change; ASCII-only prints on all platforms.
Verified: python -m py_compile passes on all three files.
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.
Problem
On Windows consoles with cp1252 encoding (default for many installs), print statements containing emoji raise
UnicodeEncodeError: 'charmap' codec can't encode character '\u274c'. This hits users of the Python compress sub-skill and obscures real error messages.The project's own CLAUDE.md already flags cross-platform hook concerns, and this is the same class of bug in the Python side.
Reproducer
Windows 11, stock cmd/PowerShell, cp1252 console:
Fix
Replace emoji prints with ASCII equivalents in three files:
caveman-compress/scripts/cli.py— 4 sites (file-not-found, not-a-file, compression-failed, generic exception)caveman-compress/scripts/compress.py— 3 sites (backup-exists warning, validation-failed, retries-exhausted)caveman-compress/scripts/benchmark.py— 4 sites (pass/fail markers, not-found errors)Mapping:
\u274c→[ERROR]\u26a0→[WARNING]\u2705→[OK]No behavior change. Prints render identically on Unix terminals; Windows cp1252 terminals now see the intended message.
Alternative considered
sys.stdout.reconfigure(encoding='utf-8')at module load — works but changes global stdout behavior and can interfere with tools that parse subprocess output. ASCII is safer.Verify
Passes.