Reputation: 10905
I have utf8 information coming for a mysql database. I want to use console.log to output it to the console.
but it shows "box" characters instead of the utf8 data.
Where am I loosing the data ? and what should I do to fix this ? is the problem when reading the data from the DB ? (using felixge-node-mysql-v0.9.5-1) or during output to the console? (using console.log) ot maybe its the console itself (windows command window set to font "Lucida Console")
Thanks.
UPDATE: I now believe its an issue with the fonts of the windows command window. when I run the same node script using a powershell window I do see different chars that don't look like what I expect. whoever, when I Try to paste then into this browser window they suddenly change to the right font and chars.
Upvotes: 3
Views: 4811
Reputation: 10905
Although I would still love a better solution what I have found for now is the following solution that works for me:
I will use Windows PowerShell ISE.
Inside it I ran the following command:
chcp 65001
running node.exe my.js from the lowest pane in WPSISE results in the exact printout I wanted in the middle pane.
Another point to mention is that if I try to open a cmd.exe window and run chcp 65001
in it and then execute my script I get
node.js:284 throw new Error('process.stdout cannot be closed');
Upvotes: 1