[BUG] Edit tool cannot distinguish between straight and curved quotes in replacements
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.21 (Claude Code)
- Operating System: Linux 5.15.167.4-microsoft-standard-WSL2
- Terminal: WSL2
Bug Description
The Edit tool fails to properly handle Unicode character replacements when characters are visually similar but have different byte representations. Specifically, the tool cannot distinguish between straight quotes (U+0027 ') and curved quotes (U+2018 ‘ and U+2019 ’), returning "No changes to make: old_string and new_string are exactly the same" even when hex dumps show the characters have different byte sequences.
Steps to Reproduce
- Create a file containing text with straight quotes around a placeholder:
'%s' - Attempt to use the Edit tool to replace the straight quotes with curved quotes:
‘%s’ - The Edit tool will claim no changes are needed despite the Unicode characters being different
- Verify with
hexdump -Cthat the characters have different byte representations:
- Straight quotes:
27(U+0027) - Curved quotes:
e2 80 98(U+2018) ande2 80 99(U+2019)
Expected Behavior
The Edit tool should successfully replace the straight quotes with curved quotes, recognizing that they are different Unicode characters despite visual similarity.
Actual Behavior
The Edit tool returns "No changes to make: old_string and new_string are exactly the same" and fails to perform the replacement, even though the characters are demonstrably different at the byte level.
Additional Context
This issue was discovered while trying to standardize quote usage in documentation. The problem prevents proper Unicode character normalization and could affect any scenario where visually similar but distinct Unicode characters need to be replaced. The hex dump evidence clearly shows the characters are different:
- Line with straight quotes:
27 25 73 27('%s') - Line with curved quotes:
e2 80 98 25 73 e2 80 99(‘%s’)
This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗