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
const fs = require('fs'); | |
// our demo string is in 'default' utf8 with emoji character assuming you are using an editor that supports those. | |
// if not, you can test this gist by setting utf8string to the equivalent '->\ud83d\ude03\ud83e\uddd2\ud83c\udffc\u00fc\u010d\u0113<-' | |
// gist doesn't support all ZWJ sequences, so can't show this here but it works with those as well, e.g. '\ud83d\udc68\ud83c\udffc\u200d\ud83d\udcbb' | |
const utf8string = '->😃🧒🏼üčē<-'; | |
// this is what you'd usually do to write to a utf-8 encoded file | |
fs.writeFileSync('test-utf8.txt', utf8string); |