Skip to content

Fix: Explicit UTF-8 encoding for cross-platform file reading#19

Open
AQGitHbu wants to merge 1 commit intopeteromallet:mainfrom
AQGitHbu:fix/encoding-utf8
Open

Fix: Explicit UTF-8 encoding for cross-platform file reading#19
AQGitHbu wants to merge 1 commit intopeteromallet:mainfrom
AQGitHbu:fix/encoding-utf8

Conversation

@AQGitHbu
Copy link

@AQGitHbu AQGitHbu commented Mar 2, 2026

Problem

On Windows (especially Chinese/Asian locales) and some other systems, the default file encoding is not UTF-8. This causes UnicodeDecodeError when reading session files that contain non-ASCII characters.

Solution

Explicitly specify encoding="utf-8" in all open() and read_text() calls when reading JSON files.

Changes

  • Line 82: Add encoding="utf-8" to read_text() in _extract_project_path_from_sessions()
  • Line 124: Add encoding="utf-8" to open() in _iter_jsonl()
  • Line 266: Add encoding="utf-8" to read_text() in _load_kimi_work_dirs()

Benefits

  1. Cross-platform compatibility (Windows, Linux, macOS)
  2. Consistent behavior regardless of system locale
  3. Properly handles session files with non-ASCII content

On Windows (especially Chinese/Asian locales) and some other systems,
the default file encoding is not UTF-8. This causes UnicodeDecodeError
when reading session files that contain non-ASCII characters.

This fix explicitly specifies encoding="utf-8" in all open() and
read_text() calls when reading JSON files.

Changes:
- Line 82: Add encoding="utf-8" to read_text() in _extract_project_path_from_sessions()
- Line 124: Add encoding="utf-8" to open() in _iter_jsonl()
- Line 266: Add encoding="utf-8" to read_text() in _load_kimi_work_dirs()
@woct0rdho
Copy link
Contributor

There are more places that we need to specify encoding="utf-8". I think an easier way is to force it run in Python UTF-8 mode.

You can see other fixes I did to support Windows at woct0rdho/dataclaw@anonymizer...windows

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.

2 participants