davidmarkclements / 0x

🔥 single-command flamegraph profiling 🔥

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Certain characters get output as a broken ASCII code in logs and output in Node 8 and 10

AlanSl opened this issue · comments

This is a quirk I found while working on #203 but couldn't find a good fix in that PR. Doesn't happen in Node 11, only 10 (and to a lesser extent, 8).

Unicode characters in the basic multilingual plane work fine in 0x paths, regexes and even method names (tip: don't do this!) with that PR, but there are a few characters that were coming up in what looks like a mangled version of ASCII encoding.

For example, if it contains ñ and æ, which both exist in ASCII (escape codes \\xF1 and \\xe6):

D:\\Documeñts and Sættings\\Александра ǂǐ-sì\\internal

...it comes out in the isolate log, JSON, and output as:

D:\\Docume\\xfffffff1ts and S\\xffffffe6ttings\\Александра ǂǐ-sì\\internal

image

In Node 8, it does the same thing but not elongated:

D:\\Docume\\xf1ts and S\\xe6ttings\\Александра ǂǐ-sì\\internal

image

In Node 11, everything is as expected:

D:\\Documeñts and Sættings\\Александра ǂǐ-sì\\internal

image

We could probably fix this with a similar approach to unicode on node 8, something like .match(/\\xf{6)?[0-9A-Fa-f]{2}/ then force it to convert with JSON.parse(), but it feels like that might be papering over some cracks.

ah ok - we had this problem with windows in Pino logging as well. It's a known bug with Node + cmd.exe/powershell - @mcollina documented it for pino here https://github.com/pinojs/pino/pull/552/files

Try running chcp 65001 in the terminal first and see if the behaviour changes

🤔 Probably a similar underlying cause, but I'm seeing this on Mac as well as windows

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

This issue was closed because it has been stalled for 5 days with no activity.