fix: UTF-8 terminal rendering — atob() decodes as Latin-1, not UTF-8
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m5s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m5s
atob() returns a "binary string" where each byte is a Latin-1 char code.
Multi-byte UTF-8 sequences (box-drawing, em dashes, arrows) were split
into separate Latin-1 codepoints, producing mojibake. Now reconstructs
the raw byte array and decodes via TextDecoder('utf-8') before writing
to xterm.js.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1d61b1faf2
commit
9fce0b6c1e
@ -114,8 +114,14 @@ export function useTerminal(sessionId: string): UseTerminalReturn {
|
||||
}
|
||||
|
||||
try {
|
||||
const decoded = atob(b64data);
|
||||
terminal.write(decoded);
|
||||
// atob() returns Latin-1 — each byte becomes a char code 0x00–0xFF.
|
||||
// We must reconstruct the raw bytes, then decode as UTF-8.
|
||||
const binaryStr = atob(b64data);
|
||||
const bytes = new Uint8Array(binaryStr.length);
|
||||
for (let i = 0; i < binaryStr.length; i++) {
|
||||
bytes[i] = binaryStr.charCodeAt(i);
|
||||
}
|
||||
terminal.write(new TextDecoder().decode(bytes));
|
||||
} catch {
|
||||
// Fallback: write raw if not valid base64
|
||||
terminal.write(b64data);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user