Skip to content

Commit f30e88e

Browse files
committed
fix: add UTF-8 encoding support for VSCode terminal output on Windows
- Add LANG and LC_ALL environment variables set to en_US.UTF-8 - Add Windows-specific CHCP=65001 for UTF-8 code page support - Update tests to verify UTF-8 encoding environment variables - This fixes non-ASCII characters (Cyrillic, Chinese, Hindi, etc.) being displayed as '?' or diamond symbols Fixes #8530
1 parent 85b0e8a commit f30e88e

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/integrations/terminal/Terminal.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ export class Terminal extends BaseTerminal {
157157
// VTE must be disabled because it prevents the prompt command from executing
158158
// See https://wiki.gnome.org/Apps/Terminal/VTE
159159
VTE_VERSION: "0",
160+
161+
// Ensure UTF-8 encoding for proper Unicode character display
162+
// This fixes issues with non-ASCII characters (Cyrillic, Chinese, Hindi, etc.)
163+
// being displayed as "?" or diamond symbols in terminal output
164+
LANG: "en_US.UTF-8",
165+
LC_ALL: "en_US.UTF-8",
166+
}
167+
168+
// On Windows, set the code page to UTF-8 (65001) for proper Unicode support
169+
if (process.platform === "win32") {
170+
env.CHCP = "65001"
160171
}
161172

162173
// Set Oh My Zsh shell integration if enabled

src/integrations/terminal/__tests__/TerminalRegistry.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ describe("TerminalRegistry", () => {
4848
PAGER,
4949
VTE_VERSION: "0",
5050
PROMPT_EOL_MARK: "",
51+
LANG: "en_US.UTF-8",
52+
LC_ALL: "en_US.UTF-8",
5153
},
5254
})
5355
})
@@ -69,6 +71,8 @@ describe("TerminalRegistry", () => {
6971
PROMPT_COMMAND: "sleep 0.05",
7072
VTE_VERSION: "0",
7173
PROMPT_EOL_MARK: "",
74+
LANG: "en_US.UTF-8",
75+
LC_ALL: "en_US.UTF-8",
7276
},
7377
})
7478
} finally {
@@ -91,6 +95,8 @@ describe("TerminalRegistry", () => {
9195
VTE_VERSION: "0",
9296
PROMPT_EOL_MARK: "",
9397
ITERM_SHELL_INTEGRATION_INSTALLED: "Yes",
98+
LANG: "en_US.UTF-8",
99+
LC_ALL: "en_US.UTF-8",
94100
},
95101
})
96102
} finally {
@@ -112,11 +118,48 @@ describe("TerminalRegistry", () => {
112118
VTE_VERSION: "0",
113119
PROMPT_EOL_MARK: "",
114120
POWERLEVEL9K_TERM_SHELL_INTEGRATION: "true",
121+
LANG: "en_US.UTF-8",
122+
LC_ALL: "en_US.UTF-8",
115123
},
116124
})
117125
} finally {
118126
Terminal.setTerminalZshP10k(false)
119127
}
120128
})
129+
130+
it("adds CHCP=65001 on Windows for UTF-8 support", () => {
131+
// Mock platform as Windows
132+
const originalPlatform = process.platform
133+
Object.defineProperty(process, "platform", {
134+
value: "win32",
135+
writable: true,
136+
configurable: true,
137+
})
138+
139+
try {
140+
TerminalRegistry.createTerminal("/test/path", "vscode")
141+
142+
expect(mockCreateTerminal).toHaveBeenCalledWith({
143+
cwd: "/test/path",
144+
name: "Roo Code",
145+
iconPath: expect.any(Object),
146+
env: {
147+
PAGER: "",
148+
VTE_VERSION: "0",
149+
PROMPT_EOL_MARK: "",
150+
LANG: "en_US.UTF-8",
151+
LC_ALL: "en_US.UTF-8",
152+
CHCP: "65001",
153+
},
154+
})
155+
} finally {
156+
// Restore original platform
157+
Object.defineProperty(process, "platform", {
158+
value: originalPlatform,
159+
writable: true,
160+
configurable: true,
161+
})
162+
}
163+
})
121164
})
122165
})

0 commit comments

Comments
 (0)