Thursday, 18 May 2017

How to output emoji to console in Node.js (on Windows)?

On Windows, there's some basic emoji support in the console, so that I can get a monochrome glyph if I type, e.g. or 📜. I can output a string from PowerShell or a C# console application or Python and they all show those characters fine enough.

However, from Node.js, I can only get a couple of emoji to display (e.g. ), but not other (instead of 📜 I see ). However, if I throw a string with those characters, they display correctly.

console.log(' 📜 ☕ ');
throw ' 📜 ☕ ';

If I run the above script, the output is

 � ☕

C:\Code\emojitest\emojitest.js:2
throw ' 📜 ☕ '; 
^
 📜 ☕

Is there anyway that I can output those emojis correctly without throwing an error? Or is that exception happening outside of what's available to me through the standard Node.js APIs?



via bdukes

No comments:

Post a Comment