feature(win) restore codepage before quit

This commit is contained in:
coderaiser 2014-07-03 09:24:28 -04:00
parent 9cab2fcba4
commit ec1a7c5f99

View file

@ -65,13 +65,37 @@
* windows use unicode on non English versions
*/
if (process.platform === 'win32')
exec('chcp 65001', function(error, stdout, stderror) {
if (error)
console.log(error);
if (stderror)
console.log(stderror);
});
if (process.platform === 'win32')
getCodePage(function(codepage) {
if (codepage) {
process.on('SIGINT', function() {
exec('chcp ' + codepage, function() {
process.exit();
});
});
exec('chcp 65001', function(error, stdout, stderror) {
if (error)
console.log(error);
if (stderror)
console.log(stderror);
});
}
});
}
function getCodePage(callback) {
exec('chcp', function(error, stdout, stderror) {
var index, codepage;
if (!error && !stderror && stdout) {
index = stdout.indexOf(':');
codepage = stdout.slice(index + 2);
}
callback(codepage);
});
}
})();