[BUG] File attachment ingestion misreads UTF-8 as Latin-1 on macOS (mojibake in document content sent to model)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- Platform: macOS (Darwin 25.4.0)
- Claude Code: VSCode extension 2.1.112 (darwin-arm64)
Description
When attaching a UTF-8 text file to a Claude Code chat, the file's bytes are
read as Latin-1/Windows-1252 before being serialized into the <document_content>
sent to the model. Non-ASCII characters arrive doubly-encoded (mojibake) at
the model, even though the file on disk is valid UTF-8.
Bypass that works
Reading the same file via the Read tool (after providing its absolute path
in the prompt instead of attaching it) produces correct UTF-8. So only the
attachment pipeline is affected, not the Read tool path.
Why this is distinct from existing issues
This is the same Latin-1-vs-UTF-8 family as #9723 (MCP results), #1716 (Write),
#7134 (Edit), #13363 (Write/BOM), but on a different surface (file attachment
ingestion) and a different platform (macOS, while most prior reports are
Windows or Linux). No existing issue covers this combination.
What Should Happen?
Expected vs Observed
| | Bytes | Decoded as UTF-8 | Sent to model |
|---|---|---|---|
| Expected | 63 61 66 c3 a9 0a | café\n | café |
| Observed | (same on disk) | (same) | café |
The on-disk bytes are unchanged. The corruption happens during ingestion: bytesc3 a9 are interpreted as two Latin-1 codepoints (U+00C3, U+00A9) → re-encoded
as UTF-8 → 4 bytes c3 83 c2 a9 reaching the model.
Error Messages/Logs
Steps to Reproduce
Minimal reproduction
- Create a file
cafe_test.mdcontaining exactlycafé\n(6 bytes UTF-8):
```
$ printf 'café\n' > cafe_test.md
$ xxd cafe_test.md
00000000: 6361 66c3 a90a caf...
é
The is correctly encoded as c3 a9` (2 bytes UTF-8).
- Attach the file to a Claude Code chat (drag-drop or paperclip).
- Ask Claude to quote the file content verbatim. Observed:
café.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.112
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗