fix(windows): add UTF-8 encoding for subprocess calls in terminal backends #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述
在 Windows 中文环境下,WeztermBackend 和 Iterm2Backend 的 subprocess 调用会因为默认使用 GBK 编码而导致解码失败:
这会导致:
ccb status无法正常检查终端状态is_alive()方法失败解决方案
为所有 subprocess.run 调用添加
encoding='utf-8'和errors='replace'参数,确保在 Windows 环境下使用 UTF-8 编码。影响的方法
WeztermBackend.is_alive()- lib/terminal.py:316WeztermBackend.create_pane()- lib/terminal.py:371Iterm2Backend.is_alive()- lib/terminal.py:210Iterm2Backend.create_pane()- lib/terminal.py:237测试环境
相关提交
这个修复补充了之前的 Windows 兼容性改进工作,与以下提交相关: