Created
March 29, 2012 16:42
-
-
Save isaacs/2239665 to your computer and use it in GitHub Desktop.
This is working in node 0.7.7
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
$ node unicode.js | |
buf= <Buffer 5b 22 f0 9f 92 a9 22 0a 2c 22 f0 9f 98 81 22 0a 2c 22 5c 75 64 38 33 64 5c 75 64 63 61 39 22 0a 2c 22 5c 75 64 38 33 64 5c 75 64 65 30 31 22 0a 5d 0a> | |
str= ["π©" | |
,"π" | |
,"\ud83d\udca9" | |
,"\ud83d\ude01" | |
] | |
obj= [ 'π©', 'π', 'π©', 'π' ] | |
obj[0]= π© | |
obj[0].length= 2 | |
obj[0].charAt(0)= ? | |
obj[0].charCodeAt(0)= d83d | |
obj[0].charAt(1)= ? | |
obj[0].charCodeAt(1)= dca9 | |
obj[1]= π | |
obj[1].length= 2 | |
obj[1].charAt(0)= ? | |
obj[1].charCodeAt(0)= d83d | |
obj[1].charAt(1)= ? | |
obj[1].charCodeAt(1)= de01 | |
obj[2]= π© | |
obj[2].length= 2 | |
obj[2].charAt(0)= ? | |
obj[2].charCodeAt(0)= d83d | |
obj[2].charAt(1)= ? | |
obj[2].charCodeAt(1)= dca9 | |
obj[3]= π | |
obj[3].length= 2 | |
obj[3].charAt(0)= ? | |
obj[3].charCodeAt(0)= d83d | |
obj[3].charAt(1)= ? | |
obj[3].charCodeAt(1)= de01 |
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 fs = require("fs") | |
var buf = fs.readFileSync("unicode.json") | |
console.error("buf=", buf) | |
var str = buf.toString("utf8") | |
console.error("str=", str) | |
var obj = JSON.parse(str) | |
console.error("obj=", obj) | |
obj.forEach(function (char, pos) { | |
console.error("obj[%d]=", pos, obj[pos]) | |
console.error("obj[%d].length=", pos, obj[pos].length) | |
for (var i = 0; i < obj[pos].length; i ++) { | |
console.error("obj[%d].charAt(%d)=", pos, i, obj[pos].charAt(i)) | |
console.error("obj[%d].charCodeAt(%d)=", pos, i, obj[pos].charCodeAt(i).toString(16)) | |
} | |
}) |
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
["π©" | |
,"π" | |
,"\ud83d\udca9" | |
,"\ud83d\ude01" | |
] |
@isaacs The rendering depends on the browser. It works in Opera and Safari. Chrome does not support Emoji. Firefox displays the Emoji, but uses the non-colored OS X-style glyphs.
Ahh, I see. Thanks, for the clarification, @mathiasbynens.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The font that github uses for code apparently doesn't have glyphs for poo face and smiling eyes.