You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Command prompt internal command more works fine, it prints Љ test. I guess Node.js does not support the 65001 codepage, which is ok, but maybe better error message would be appropriate (if the default codepage is 65001, it may be hard for users to find out what the problem is, since console.log gives no output at all).
The reason console.log() is silent is because console._ignoreErrors === true.
As to providing a better error message: Windows doesn't really give us anything beyond "something went wrong."
The error happens deep inside libuv (src/win/tty.c) when it calls GetConsoleScreenBufferInfo() or one of the SetConsole*() functions. They fail with a generic error that libuv reports as UV_EIO.
Even with console._ignoreErrors === false no output is generated if any file name on the stack trace contains unsupported characters. But, for example, Python's error is more user-friendly:
Traceback (most recent call last):
File "test.py", line 1, in <module>
print(u'\u0409test')
LookupError: unknown encoding: cp65001
Node.js can call GetACP if the write operation fails and if the code page is unsupported, display an appropriate error. I spent some time trying to fix this, but seems like it is not worth that effort for such an edge case.
I've been trying to reason about why it fails with the UTF-8 code page. Libuv is pretty much code page-agnostic.
It uses the wide-character Windows APIs (e.g. WriteConsoleW() rather than WriteConsoleA()) to display text, and converts from UTF-8 to UTF-16 before passing it down.
If the console code page is 65001, printing a character outside ASCII range disables stdout. For example
prints nothing (no output, no errors). Exit code is 0.
Using
process.stdout
throws an error:gives:
Using
fs
module works somewhat:Output:
Command prompt internal command
more
works fine, it printsЉ test
. I guess Node.js does not support the 65001 codepage, which is ok, but maybe better error message would be appropriate (if the default codepage is 65001, it may be hard for users to find out what the problem is, sinceconsole.log
gives no output at all).Possibly related: #11470 and #11469
The text was updated successfully, but these errors were encountered: