Skip to content
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

Unreadable error messages in console by national code pages #95

Open
VadimDor opened this issue Sep 6, 2017 · 2 comments
Open

Unreadable error messages in console by national code pages #95

VadimDor opened this issue Sep 6, 2017 · 2 comments

Comments

@VadimDor
Copy link

VadimDor commented Sep 6, 2017

Error messages in console are not readable at some locales. E.g. by russian locale on Windows we have following for "command not found" error:

""unexisting-command"" �� ���� ����७��� ��� ���譥�
��������, �ᯮ��塞�� �ணࠬ��� ��� ������ 䠩���.

instead of

""unexisting-command"" не является внутренней или внешней
командой, исполняемой программой или пакетным файлом.

The solution were to decode the message first in module sb-exec file index.js:

reject(new Error((new TextDecoder('IBM866')).decode(data.stderr[0]).trim()));

instead of (e.g. line 41)

reject(new Error(data.stderr.join('').trim()));

The same probably is valid also for stdout (e.g. line 59 there).

To set valid encoding for TextDecoder() is either up to user over API (should be extended) or some package to guess encoding from buffer could be used (e.g. this one https://github.com/sonicdoe/detect-character-encoding ) or first execute some test command on os (e.g. "chcp" on Windows)

@Arcanemagus
Copy link
Collaborator

Unfortunately it looks like detect-character-encoding requires being built on Windows, which is unlikely to succeed on most people's machines.

@Arcanemagus
Copy link
Collaborator

So far the best I've come up with is running chcp, and hardcoding this table in as a lookup for the real encoding, since the utility that would give that isn't availabe on Windows unless you've installed the resource kit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants