Skip to content

Optimize stdout&stderr decoding for Windows ANSI Code Page #16

@asinbow

Description

@asinbow

master...asinbow:patch-1

This is actually is NOT a PR, but a suggestion.
I have seen whole content of issue #9, and changes in

static async enableUnicode() {
.
cmd.exe /c chcp has side effect, and I think it should be the only choice.
In our own application we have implemented a function ChangeCodePage by using node-ffi:

const ChangeCodePage = (buffer, options = {}) => {
  const {
    fromCodePage = 'acp',
    toCodePage = 'utf8',
    toString = true,
    nullTerminated = false,
  } = options;
  // using Windows API WideCharToMultiByte and MultiByteToWideChar
  return WideCharToMultiByte(MultiByteToWideChar(buffer, fromCodePage), {
    encoding: toCodePage,
    toString,
    nullTerminated,
  });
};

So, if there is a Registry.decodeStdout option, life would be much easier!
💯

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions