Created
April 26, 2013 18:09
-
-
Save chockenberry/5469201 to your computer and use it in GitHub Desktop.
Unicode trim 2
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 buf_ucs2 = new Buffer([0x35,0xD8,0x9c,0xDC]) | |
undefined | |
> buf_ucs2.toString('ucs2') | |
'π' | |
> var str = buf_ucs2.toString('ucs2') | |
undefined | |
> str | |
'π' | |
> var buf_utf8 = new Buffer(str, 'utf8') | |
undefined | |
> buf_utf8.toString('utf8') | |
'π' | |
> var result = buf_ucs2.toString('ucs2') | |
undefined | |
> result | |
'π' | |
> var result = buf_ucs2.toString('utf8') | |
undefined | |
> result | |
'5ΨοΏ½' | |
> result.length | |
3 | |
> result.charCodeAt(0).toString(16) | |
'35' | |
> result.charCodeAt(1).toString(16) | |
'61c' | |
> result.charCodeAt(2).toString(16) | |
'fffd' | |
> var result = buf_utf8.toString('ucs2') | |
undefined | |
> result | |
'ι·°ι²' | |
> var result = buf_utf8.toString('utf8') | |
undefined | |
> result | |
'π' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment