Skip to content

Instantly share code, notes, and snippets.

@fengmk2
Created October 20, 2011 17:04
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 fengmk2/1301674 to your computer and use it in GitHub Desktop.
Save fengmk2/1301674 to your computer and use it in GitHub Desktop.
> var b = new Buffer(2)
> b
<Buffer 00 00>
> b[0] = 0xcb
203
> b
<Buffer cb 00>
> b[1] = 0xd5
213
> b
<Buffer cb d5>
> b.toString()
'��'
> var Iconv = require('iconv').Iconv;
> var iconv = new Iconv('gbk', 'utf-8')
> iconv
{}
> iconv.convert(b)
<SlowBuffer e8 8b 8f>
> iconv.convert(b).toString()
'苏'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment