Created
October 4, 2012 06:36
-
-
Save siygle/3831835 to your computer and use it in GitHub Desktop.
Convert Big5 to UTF8 using node-iconv
This file contains hidden or 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 http = require('http') | |
| , Buffer = require('buffer').Buffer | |
| , Iconv = require('iconv').Iconv; | |
| var options = { | |
| host: 'mis.tse.com.tw', | |
| path: '/data/4930.csv?r=' + new Date().getTime(), | |
| method: 'GET', | |
| }; | |
| var iconv = new Iconv('Big5', 'UTF8'); | |
| var req = http.request(options, function(res) { | |
| res.on('data', function(data) { | |
| var buffer = iconv.convert(data); | |
| console.log(buffer.toString('utf-8')); | |
| }); | |
| }); | |
| req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing!