fix: use platform-aware UTF-8 locale fallback for PTY (#1137)
C.UTF-8 does not exist on macOS, causing the terminal to fall back to ASCII encoding when LANG is unset. Use en_US.UTF-8 on macOS and C.UTF-8 on Linux. Also set LC_CTYPE with the platform-appropriate value (UTF-8 on macOS, C.UTF-8 on Linux) for additional safety.
This commit is contained in:
@@ -121,6 +121,9 @@ export function createTerminalRuntime({
|
||||
return resolved;
|
||||
};
|
||||
|
||||
const utf8LocaleFallback = process.platform === 'darwin' ? 'en_US.UTF-8' : 'C.UTF-8';
|
||||
const lcCtypeFallback = process.platform === 'darwin' ? 'UTF-8' : 'C.UTF-8';
|
||||
|
||||
const spawnTerminalPtyWithFallback = (pty, { cols, rows, cwd, env }) => {
|
||||
const shellCandidates = getTerminalShellCandidates();
|
||||
if (shellCandidates.length === 0) {
|
||||
@@ -139,7 +142,8 @@ export function createTerminalRuntime({
|
||||
...env,
|
||||
TERM: 'xterm-256color',
|
||||
COLORTERM: 'truecolor',
|
||||
LANG: env.LANG || process.env.LANG || 'C.UTF-8',
|
||||
LANG: env.LANG || process.env.LANG || utf8LocaleFallback,
|
||||
LC_CTYPE: env.LC_CTYPE || process.env.LC_CTYPE || lcCtypeFallback,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user