-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: writing utf8 to fd 1 results in garbled output on windows #24550
Comments
This might be related to libuv @nodejs/libuv @nodejs/platform-windows. |
Windows console does not speak UTF-8 (yet.. and some more details). Libuv converts UTF-8 to UCS-2 before writing to TTY: Line 1675 in 69cc58d
|
To elaborate on @bzoz > s = new tty.WriteStream(1)
> s.write('èè\n');
èè
true and in Windows Insider build 18282: > const fs = require('fs')
undefined
> const str = 'èè'
undefined
> fs.write(1, str + '\n', 0, '', console.log)
èè
undefined
> null 5 èè |
Note that writing: const fs = require('fs')
const str = 'èè'
fs.write(1, str + '\n', null, 'ucs2', console.log) does not work either. |
Is there anything Node can or should do about it? Silently converting text seems like a bad idea. |
IMO - Document as known limitation. |
P.S. @mcollina does the info in https://ss64.com/nt/chcp.html help (run |
const fs = require('fs')
const str = 'èè'
fs.write(1, str + '\n', null, 'utf8', console.log) |
Fixes: nodejs#24550 PR-URL: nodejs#24571 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Fixed in 086482d |
Fixes: nodejs#24550 PR-URL: nodejs#24571 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
The following snipped works fine on Linux and Mac OS X, but not on Windows:
Note that using
process.stdout.write
is actually working as expected.The text was updated successfully, but these errors were encountered: