3

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.

1
  • Sounds like either your terminal(s) use fonts that don't contain glyphs for the characters you're printing, or they are set to an encoding other than UTF8. Commented Jun 4, 2012 at 9:21

1 Answer 1

1

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');

Sign up to request clarification or add additional context in comments.

1 Comment

in my case instead of box, the thin space (\u200B) is actually outputted as ΓÇï (on console & file redirection both) and the solution didn't worked. Did you ran into any such scenario ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.