Node and emojis - No Smiley?

I have been playing recently with a world tweet map (available here, login via twitter required), and one of the things I noticed last weekend was that all of the special characters used in tweets were not being displayed correctly. This stinks when displaying tweets, because they occur all the time. Instead of the smileys and all the other silly things, there were just square boxes displayed.

It turns out that there seems to be an issue sometimes with either node.js or Chrome with emojis. I haven't researched this completely, but one thing that seemed to help out here was to use the emojis node module by fengmk2 when putting showing the relevant html. Using this module is really simple - just load it via require and call emoji.unitfiedToHTML(text). As you can see in the example below, this does not seem to work for all emojis. The node module uses a sprite sheet, so there are likely a few still missing. And it still seems to be quirky in an svg text element in Chrome. However, it's better than having only little squares across the board.

Getting a few happy emojis to
display in a node app
via the emojis node module.
You can see it in use at this world tweet map app

I was looking at the app with the Safari browser, and I didn't see the same issues, which is why I think there might be something Chrome-specific going on here.

And maybe there's a 100% solution available - I haven't found it yet.

Popular Posts