encoding - still ignore 'ascii'

This commit is contained in:
Benjamin Pasero
2019-11-12 18:48:27 +01:00
parent b66599bbfd
commit ddfca307b1
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -210,6 +210,17 @@ async function guessEncodingByBuffer(buffer: Buffer): Promise<string | null> {
return null;
}
// Ignore 'ascii' as guessed encoding because that
// is almost never what we want, rather fallback
// to the configured encoding then. Otherwise,
// opening a ascii-only file with auto guessing
// enabled will put the file into 'ascii' mode
// and thus typing any special characters is
// not possible anymore.
if (guessed.encoding.toLowerCase() === 'ascii') {
return null;
}
return toIconvLiteEncoding(guessed.encoding);
}