Skip to content

Instantly share code, notes, and snippets.

@Zulcom
Created February 19, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zulcom/8e3abfa6f2cda6e4b69704ec4957d659 to your computer and use it in GitHub Desktop.
Save Zulcom/8e3abfa6f2cda6e4b69704ec4957d659 to your computer and use it in GitHub Desktop.
Node.js конвертирование всех файлов в каталоге из кодировки 866 в кодировку UTF-8(BOM)
// Node.js конвертирование всех файлов в каталоге из кодировки 866 в кодировку UTF-8(BOM)
// Node.js convert all files in directory from 866 codepage to UTF-8 (BOM)
var fs = require('fs');
var cptable = require('codepage');
fs.readdir('jav/', function (err, filenames) {
filenames.forEach(function (filename) {
fs.readFile('jav/' + filename, null, function (err, content) {
fs.appendFile("jav-utf/" + filename, cptable.utils.decode(866, content), function (err) {
console.log(filename);
});
});
});
});
{
"name": "Zulcom file converter",
"version": "1.0.0",
"description": "Node.js convert 866 codepage to UTF-8 (BOM)",
"main": "encoding.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": {
"name": "Semon Muravyov",
"url": "https://github.com/Zulcom/"
},
"license": "MIT",
"dependencies": {
"codepage": "^1.12.0",
"encoding": "^0.1.12"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment