Улучшил распознавание кодировки

This commit is contained in:
Book Pauk
2019-01-22 04:49:46 +07:00
parent 40f0521bce
commit 0da6d30fc8

View File

@@ -140,7 +140,17 @@ class BookConverter {
});
*/
await parser.parse(iconv.decode(data, chardet.detect(data)));
const charsetAll = chardet.detectAll(data);
let selected = 'ISO-8859-1';
for (const charset of charsetAll) {
if (charset.name.indexOf('ISO-8859') < 0) {
selected = charset.name;
break;
}
}
await parser.parse(iconv.decode(data, selected));
const title = (titleInfo['book-title'] ? titleInfo['book-title'] : '');
let author = '';