Created
May 17, 2014 09:58
-
-
Save tonyc726/650f4507fd3aaf9bf872 to your computer and use it in GitHub Desktop.
nodeJS小记
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var iconv = require('iconv-lite'); | |
fs.readFile('./a_uft8.md', function(err, data) { | |
if (err) { | |
console.error(err); | |
} else { | |
var str = iconv.decode(data, 'utf-8'); | |
var str2 = iconv.encode(str, 'gbk') | |
var str3 = iconv.decode(str2, 'gbk') | |
console.log(data) | |
fs.writeFile('./b_gbk.md', str2, null, function (err) { | |
if (err) throw err; | |
console.log('It\'s saved!'); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment