Skip to content

Commit

Permalink
some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
naogify committed Feb 9, 2024
1 parent a988a7a commit c53014d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/convertToUtf8.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ const convertToUtf8 = (content) => {
return iconv.decode(content, 'Shift_JIS');
}

return content;
// UTF-8 と判定された場合はそのまま返す
if (detectedEncoding === 'UTF-8') {
return content;
}

return false;
}

module.exports = convertToUtf8;
6 changes: 6 additions & 0 deletions bin/excel2geojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const excelToGeoJson = async (inputDir) => {
} else if (file.path.endsWith(".csv")) {
csvData = await readFile(file.path);
csvData = convertToUtf8(csvData);

if (!csvData) {
console.log(`Error: CSV データ ${file.path} を UTF-8 に変換できませんでした。`);
continue;
}

csvData = csvData.toString('utf-8');
}

Expand Down

0 comments on commit c53014d

Please sign in to comment.