← 返回 Skills 市场
gkd2323c

Charset Fix

作者 gkd2323c · GitHub ↗ · v1.0.0 · MIT-0
windows ✓ 安全检测通过
24
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install charset-fix
功能描述
Fix Chinese/Unicode character encoding issues when running AI agents on Windows via POSIX shells (Git Bash, MSYS2, WSL, BusyBox, etc.). Handles Python, Power...
使用说明 (SKILL.md)

Windows Character Encoding Fix for AI Agents

Fix garbled Chinese/Unicode text output when running AI agents on Windows through POSIX-compatible shells.

Problem

When AI agents run commands on Windows through POSIX shells (Git Bash, MSYS2, BusyBox, or any Unix-like shell layer), text output containing Chinese or extended Unicode characters often appears garbled:

$ python3 -c "print('中文测试')"
���IJ���  ← garbled
$ echo "中文测试"
中文测试       ← correct

Root Cause

Layer Encoding Why
Windows system GBK/GB2312 (CP936) Default code page for Chinese Windows
Python 3 GBK sys.stdout.encoding auto-detects system code page
PowerShell (powershell.exe) GB2312 [Console]::OutputEncoding defaults to system CP
cmd.exe GBK Native Windows command processor
POSIX shell (Git Bash, BusyBox, MSYS2) UTF-8 Expects UTF-8 input
PowerShell Core (pwsh.exe) UTF-8 ✅ Defaults to UTF-8, no fix needed

The mismatch: Windows-native tools output GBK-encoded text, but the POSIX shell terminal reads it as UTF-8, producing garbled characters.

Quick Fix

Python

PYTHONIOENCODING=utf-8 python3 -c "print('中文测试 ✅')"

Set it for the whole session:

export PYTHONIOENCODING=utf-8
python3 script.py

PowerShell (Windows PowerShell, not Core)

powershell.exe -NoProfile -Command "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Write-Host '中文测试'"

cmd.exe / Windows native tools

Use Python's subprocess as a GBK→UTF-8 bridge:

PYTHONIOENCODING=utf-8 python3 -c "
import subprocess
r = subprocess.run(['cmd.exe', '/c', 'systeminfo | findstr 系统'],
    capture_output=True, text=True, encoding='gbk')
print(r.stdout)
"

Code-level fix (Python)

import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

Verification

PYTHONIOENCODING=utf-8 python3 -c "print('charset-fix: 中文测试成功 ✅')"

Expected: charset-fix: 中文测试成功 ✅

How It Works

Fix Mechanism
PYTHONIOENCODING=utf-8 Overrides Python's stdout encoding detection
[Console]::OutputEncoding = UTF8 Sets PowerShell's console output to UTF-8
subprocess(..., encoding='gbk') Decodes cmd.exe output correctly, then emits as UTF-8

Compatibility

Platform Status
Windows + Git Bash ✅ Works
Windows + BusyBox ✅ Works
Windows + MSYS2 ✅ Works
Windows + WSL ✅ Works
macOS / Linux ⬜ Not needed
PowerShell Core (pwsh) ⬜ Not needed

Works with: Claude Code, Codex CLI, Cline, Cursor, GitHub Copilot, OpenClaw agents.

Debugging

# Check code page
powershell.exe -NoProfile -Command "chcp"

# Check Python encoding
python3 -c "import sys; print(sys.stdout.encoding)"

# Test raw shell output
echo "中文测试"

License

MIT

安全使用建议
This appears safe for its stated purpose. Before installing, note that its helper can run local PowerShell/cmd diagnostics, and if you use the README's GitHub-based install instructions, verify the repository source.
功能分析
Type: OpenClaw Skill Name: charset-fix Version: 1.0.0 The charset-fix skill bundle is a legitimate utility designed to resolve character encoding mismatches (GBK vs. UTF-8) on Windows POSIX environments. The instructions in SKILL.md and the logic in scripts/fix.py are transparent, focusing solely on environment configuration and diagnostic tests using standard system commands like 'chcp' and 'ver' without any signs of malicious intent or data exfiltration.
能力标签
crypto
能力评估
Purpose & Capability
The stated purpose is to fix Chinese/Unicode garbling on Windows POSIX shells, and the provided instructions and helper script are consistent with diagnosing and correcting character encoding.
Instruction Scope
The skill provides shell and Python command snippets that an agent or user may run, but they are limited to encoding configuration and diagnostics.
Install Mechanism
There is no OpenClaw install script, but the README documents an optional GitHub clone-based install path for other tools; users should verify the repository if using that path.
Credentials
The helper invokes local PowerShell and cmd.exe commands to check encoding behavior, which is proportionate to the Windows charset purpose and does not show network, file-write, or credential handling.
Persistence & Privilege
No background process, startup persistence, privileged operation, or credential use is shown; environment changes are session-scoped examples.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install charset-fix
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /charset-fix 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release – Fixes Windows character encoding issues for AI agent shells. - Ensures correct Chinese/Unicode output on Windows when using POSIX shells (Git Bash, MSYS2, WSL, BusyBox). - Fixes mismatches between GBK/CP936 output (Python, PowerShell, cmd.exe) and UTF-8 terminals. - Provides quick fixes for Python, PowerShell, and native Windows tools. - Includes compatibility and troubleshooting guidance for various environments.
元数据
Slug charset-fix
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Charset Fix 是什么?

Fix Chinese/Unicode character encoding issues when running AI agents on Windows via POSIX shells (Git Bash, MSYS2, WSL, BusyBox, etc.). Handles Python, Power... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 24 次。

如何安装 Charset Fix?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install charset-fix」即可一键安装,无需额外配置。

Charset Fix 是免费的吗?

是的,Charset Fix 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Charset Fix 支持哪些平台?

Charset Fix 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(windows)。

谁开发了 Charset Fix?

由 gkd2323c(@gkd2323c)开发并维护,当前版本 v1.0.0。

💬 留言讨论