Skip to content

Commit d09231a

Browse files
authored
Merge pull request microsoft#20932 from matheusrocha89/encoding-problem
Terminal encoding problem related to issue microsoft#14586
2 parents 743416b + 2357842 commit d09231a

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,7 @@ export class TerminalInstance implements ITerminalInstance {
562562
});
563563
}
564564
env['PTYCWD'] = cwd;
565-
if (locale) {
566-
env['LANG'] = TerminalInstance._getLangEnvVariable(locale);
567-
}
565+
env['LANG'] = TerminalInstance._getLangEnvVariable(locale);
568566
if (cols && rows) {
569567
env['PTYCOLS'] = cols.toString();
570568
env['PTYROWS'] = rows.toString();
@@ -615,12 +613,12 @@ export class TerminalInstance implements ITerminalInstance {
615613
return newEnv;
616614
}
617615

618-
private static _getLangEnvVariable(locale: string) {
619-
const parts = locale.split('-');
616+
private static _getLangEnvVariable(locale?: string) {
617+
const parts = locale ? locale.split('-') : [];
620618
const n = parts.length;
621619
const language = parts[0];
622620
if (n === 0) {
623-
return '';
621+
return 'en_US.UTF-8'; // Avoid encoding problem with special chars. Issue #14586
624622
}
625623
if (n === 1) {
626624
// app.getLocale can return just a language without a variant, fill in the variant for

src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ suite('Workbench - TerminalInstance', () => {
6969
assert.equal(env2['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
7070

7171
const env3 = TerminalInstance.createTerminalEnv(parentEnv1, shell1, '/', null);
72-
assert.ok(!('LANG' in env3), 'LANG is unset');
72+
assert.equal(env3['LANG'], 'en_US.UTF-8', 'LANG is equal to en_US.UTF-8 as fallback.'); // More info on issue #14586
7373

7474
const env4 = TerminalInstance.createTerminalEnv(parentEnv2, shell1, '/', null);
7575
assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');

0 commit comments

Comments
 (0)