mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-03 14:45:33 +00:00
check for unicode on windows using GetConsoleCP. see #130.
This commit is contained in:
parent
38cc1a3ea3
commit
5f993a19d9
23
lib/tput.js
23
lib/tput.js
@ -2020,7 +2020,7 @@ Tput.prototype.detectUnicode = function() {
|
||||
+ ':' + process.env.LC_ALL
|
||||
+ ':' + process.env.LC_CTYPE;
|
||||
|
||||
return /utf-?8/i.test(LANG);
|
||||
return /utf-?8/i.test(LANG) || (this.GetConsoleCP() === 65001);
|
||||
};
|
||||
|
||||
// For some reason TERM=linux has smacs/rmacs, but it maps to `^[[11m`
|
||||
@ -2130,6 +2130,27 @@ Tput.prototype.parseACS = function(info) {
|
||||
return data;
|
||||
};
|
||||
|
||||
Tput.prototype.GetConsoleCP = function() {
|
||||
var ccp;
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
return -1;
|
||||
}
|
||||
|
||||
try {
|
||||
ccp = cp.execFileSync(process.env.WINDIR + '\\system32\\chcp.exe', [], {
|
||||
stdio: 'pipe',
|
||||
encoding: 'ascii'
|
||||
});
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
|
||||
if (!ccp) ccp = '-1';
|
||||
|
||||
return +ccp.trim();
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user