mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
feature(win) restore codepage before quit
This commit is contained in:
parent
9cab2fcba4
commit
ec1a7c5f99
1 changed files with 32 additions and 8 deletions
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue