This commit is contained in:
Jan Prochazka 2024-05-31 08:28:20 +02:00
parent ab481121f9
commit 0d22c675b6

View File

@ -61,6 +61,7 @@ function getFileEncoding(filePath, fs) {
}
function decodeFile(buf: Uint8Array, enc: string) {
// TODO: use import instead of window.require. Requires doesn't work in built electron app
const iconv = window.require('iconv-lite');
return iconv.decode(buf, enc);
}
@ -120,8 +121,9 @@ export function openElectronFileCore(filePath, extensions) {
if (nameLower.endsWith('.sql')) {
const encoding = getFileEncoding(filePath, fs);
const buf = fs.readFileSync(filePath);
const data = decodeFile(buf, encoding);
const data = fs.readFileSync(filePath, { encoding });
// const buf = fs.readFileSync(filePath);
// const data = decodeFile(buf, encoding);
newQuery({
title: parsed.name,