From de1a01ff57fd9405dbd336dcfd5446f3ba1c819e Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Sun, 2 Oct 2016 12:54:27 -0400 Subject: [PATCH] Preserve multi-byte encoded utf-8 characters (#769) --- app/session.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/session.js b/app/session.js index 20c2efea..27ff33bc 100644 --- a/app/session.js +++ b/app/session.js @@ -1,5 +1,6 @@ const {exec} = require('child_process'); const {EventEmitter} = require('events'); +const {StringDecoder} = require('string_decoder'); const {app} = require('electron'); const defaultShell = require('default-shell'); @@ -35,6 +36,8 @@ module.exports = class Session extends EventEmitter { TERM_PROGRAM_VERSION: version }, envFromConfig); + const decoder = new StringDecoder('utf8'); + const defaultShellArgs = ['--login']; this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, { @@ -48,7 +51,7 @@ module.exports = class Session extends EventEmitter { if (this.ended) { return; } - this.emit('data', data.toString('utf8')); + this.emit('data', decoder.write(data)); }); this.pty.on('exit', () => {