Skip to content

[Bug]: read tool fails to read GBK-encoded text files on Chinese Windows (displays garbled text) #92664

Description

@dellzou

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

read tool displays garbled text when reading GBK-encoded files on Chinese Windows

Steps to reproduce

  1. On Chinese Windows 11 (default encoding GBK/codepage 936)
  2. Create a text file with GBK encoding using PowerShell:
    $content = "中文测试内容"
    [System.IO.File]::WriteAllText("test.txt", $content, [System.Text.Encoding]::Default)
    

Use OpenClaw's read tool to read the file
Observe garbled text output (mojibake)

Expected behavior

The read tool should correctly display Chinese text from GBK-encoded files, either by:

  • Auto-detecting file encoding, or
  • Respecting system default encoding on Windows, or
  • Providing an encoding parameter to specify file encoding

Actual behavior

GBK-encoded files are decoded as UTF-8, resulting in garbled text (mojibake).

Example:

  • File content (GBK): "GBK 编码测试\n公司:深圳欧盛自动化"
  • read tool output: "GBK \n˾ŷʢԶ"

UTF-8 encoded files work correctly.

OpenClaw version

2026.6.1

Operating system

Windows 11 23H2 (Chinese Simplified)

Install method

npm global

Model

qwen/qwen3.5-plus

Provider / routing chain

qwen/qwen3.5-plus → gateway

Additional provider/model setup details

No response

Logs, screenshots, and evidence

### 测试证据

**UTF-8 文件读取正常:**

**GBK 文件读取乱码:**

# 用系统默认编码 (GBK) 写入
[System.IO.File]::WriteAllText("gbk_test.txt", "中文内容", [System.Text.Encoding]::Default)
# 字节检查:前 10 字节 = 47 42 4B 20 B1 E0 C2 EB B2 E2 (GBK 编码)

write → temp/中文测试.txt (UTF-8)
read → ✅ 正常显示中文


**GBK 文件读取乱码:**

# 用系统默认编码 (GBK) 写入
[System.IO.File]::WriteAllText("gbk_test.txt", "中文内容", [System.Text.Encoding]::Default)
# 字节检查:前 10 字节 = 47 42 4B 20 B1 E0 C2 EB B2 E2 (GBK 编码)


read → temp/gbk_test.txt
输出:❌ "GBK \n˾ŷʢԶ"

Impact and severity

Affects Chinese Windows users when reading common GBK-encoded text files.
Workaround: Use exec with PowerShell to read files with explicit encoding, or convert files to UTF-8 first.

Additional information

添加 encoding 参数到 read 工具
或自动检测文件编码(通过 BOM 或内容分析)
或在 Windows 上默认使用系统编码

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.regressionBehavior that previously worked and now fails

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions