Preserve multi-byte encoded utf-8 characters (#769)

This commit is contained in:
Marshall Bowers 2016-10-02 12:54:27 -04:00 committed by Guillermo Rauch
parent 7aa20a8d45
commit de1a01ff57

View file

@ -1,5 +1,6 @@
const {exec} = require('child_process'); const {exec} = require('child_process');
const {EventEmitter} = require('events'); const {EventEmitter} = require('events');
const {StringDecoder} = require('string_decoder');
const {app} = require('electron'); const {app} = require('electron');
const defaultShell = require('default-shell'); const defaultShell = require('default-shell');
@ -35,6 +36,8 @@ module.exports = class Session extends EventEmitter {
TERM_PROGRAM_VERSION: version TERM_PROGRAM_VERSION: version
}, envFromConfig); }, envFromConfig);
const decoder = new StringDecoder('utf8');
const defaultShellArgs = ['--login']; const defaultShellArgs = ['--login'];
this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, { this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, {
@ -48,7 +51,7 @@ module.exports = class Session extends EventEmitter {
if (this.ended) { if (this.ended) {
return; return;
} }
this.emit('data', data.toString('utf8')); this.emit('data', decoder.write(data));
}); });
this.pty.on('exit', () => { this.pty.on('exit', () => {