diff --git a/src/client/common/process/proc.ts b/src/client/common/process/proc.ts index 5bd3b816e956..959d9b615f39 100644 --- a/src/client/common/process/proc.ts +++ b/src/client/common/process/proc.ts @@ -22,6 +22,9 @@ export class ProcessService implements IProcessService { // Always ensure we have unbuffered output. spawnOptions.env.PYTHONUNBUFFERED = '1'; + if (!spawnOptions.env.PYTHONIOENCODING) { + spawnOptions.env.PYTHONIOENCODING = 'utf-8'; + } const proc = spawn(file, args, spawnOptions); let procExited = false; @@ -78,7 +81,9 @@ export class ProcessService implements IProcessService { // Always ensure we have unbuffered output. spawnOptions.env.PYTHONUNBUFFERED = '1'; - + if (!spawnOptions.env.PYTHONIOENCODING) { + spawnOptions.env.PYTHONIOENCODING = 'utf-8'; + } const proc = spawn(file, args, spawnOptions); const deferred = createDeferred>(); const disposables: Disposable[] = []; diff --git a/src/test/common/process/proc.exec.test.ts b/src/test/common/process/proc.exec.test.ts index 32091f5a9ab7..8ab71804d3d2 100644 --- a/src/test/common/process/proc.exec.test.ts +++ b/src/test/common/process/proc.exec.test.ts @@ -32,6 +32,16 @@ suite('ProcessService', () => { expect(result.stderr).to.equal(undefined, 'stderr not undefined'); }); + test('exec should output print unicode characters', async () => { + const procService = new ProcessService(new BufferDecoder()); + const printOutput = 'öä'; + const result = await procService.exec(pythonPath, ['-c', `print(u"${printOutput}")`]); + + expect(result).not.to.be.an('undefined', 'result is undefined'); + expect(result.stdout.trim()).to.be.equal(printOutput, 'Invalid output'); + expect(result.stderr).to.equal(undefined, 'stderr not undefined'); + }); + test('exec should wait for completion of program with new lines', async function () { // tslint:disable-next-line:no-invalid-this this.timeout(5000);