Skip to content

Conversation

@gavin-dunlap-luminar
Copy link
Contributor

The check-shellscript-set-options hook fails on Windows when processing shell scripts containing UTF-8 characters (e.g., emojis) because it opens files without specifying an encoding, defaulting to cp1252 on Windows.

This commit adds explicit UTF-8 encoding when reading files to ensure cross-platform compatibility.

Fixes the error:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3176:
character maps to

Changes:

  • filename.read_text() -> filename.read_text(encoding='utf-8')
  • filename.open().readline() -> filename.open(encoding='utf-8').readline()

gavin-dunlap-luminar and others added 2 commits December 11, 2025 15:17
The check-shellscript-set-options hook fails on Windows when processing
shell scripts containing UTF-8 characters (e.g., emojis) because it opens
files without specifying an encoding, defaulting to cp1252 on Windows.

This commit adds explicit UTF-8 encoding when reading files to ensure
cross-platform compatibility.

Fixes the error:
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3176:
  character maps to <undefined>

Changes:
- filename.read_text() -> filename.read_text(encoding='utf-8')
- filename.open().readline() -> filename.open(encoding='utf-8').readline()
@gavin-dunlap-luminar gavin-dunlap-luminar merged commit 85fb0be into master Dec 11, 2025
8 checks passed
@gavin-dunlap-luminar gavin-dunlap-luminar deleted the fix/utf8-encoding-shellscript-check branch December 11, 2025 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants