crawl4ai
crawl4ai copied to clipboard
fix: add encoding=utf-8 to CLI file operations
Summary
On Windows, the default file encoding (e.g. charmap / cp1252) cannot encode certain Unicode characters found in crawled content, causing 'charmap' codec can't encode character errors when writing output files via the CLI.
Fixes #1762
List of files changed and why
crawl4ai/cli.py — Added encoding="utf-8" to all 6 open() calls (config read/write + 4 output file writes)
How Has This Been Tested?
- Code review: all file I/O paths in CLI now explicitly use UTF-8
- The fix matches Python best practice for cross-platform Unicode file handling
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] I have added/updated unit tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes