Skip to content

Instantly share code, notes, and snippets.

@sagan
Created September 24, 2013 07:11
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 sagan/6681294 to your computer and use it in GitHub Desktop.
Save sagan/6681294 to your computer and use it in GitHub Desktop.
// npm -g install iconv
var Iconv = require('iconv').Iconv;
var fs=require("fs");
// convert string from GBK to UTF-8
var iconv = new Iconv('GBK', 'UTF-8');
var filename = "file";
var content_buffer = fs.readFileSync(filename);
var content_buffer_utf8 = iconv.convert(content_buffer);
var content_string = content_buffer_utf8.toString("UTF-8");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment