codepage() defaults linux

This commit is contained in:
Sebastian Hildebrandt 2019-01-13 12:40:04 +01:00
parent 5f1058ded7
commit 5de7801070

View File

@ -260,10 +260,18 @@ function getCodepage() {
if (_linux || _darwin || _freebsd || _openbsd) {
if (!codepage) {
try {
const stdout = execSync('echo $LANG');
const lines = stdout.toString().split('\r\n');
const parts = lines[0].split('.');
codepage = parts.length > 1 ? parts[1].trim() : '';
const stdout = execSync('locale charmap');
let lines = stdout.toString().split('\r\n');
codepage = lines[0].trim();
if (!codepage) {
const stdout = execSync('echo $LANG');
lines = stdout.toString().split('\r\n');
const parts = lines[0].split('.');
codepage = parts.length > 1 ? parts[1].trim() : '';
if (!codepage) {
codepage = 'UTF-8';
}
}
} catch (err) {
codepage = 'UTF-8';
}