Last active
August 29, 2015 14:10
-
-
Save smikes/b4947876c4bba3fbf87e to your computer and use it in GitHub Desktop.
reading/writing UTF-8 encoded chars in node
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 fs = require('fs') | |
> fs.writeFileSync('foo', JSON.stringify({ä: 'Å'})) | |
undefined | |
> ^Z | |
[1]+ Stopped node | |
smikes$ cat foo | |
{"ä":"Å"}smikes$ fg | |
node | |
> buf = fs.readFileSync('foo') | |
<Buffer 7b 22 c3 a4 22 3a 22 c3 85 22 7d> | |
> buf | |
<Buffer 7b 22 c3 a4 22 3a 22 c3 85 22 7d> | |
> JSON.parse(buf) | |
{ 'ä': 'Å' } | |
> require('os').platform() | |
'darwin' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment