Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

win32 platform support not utf8 encoding at childProcess.spawn() stdout/stderr #364

Merged
merged 2 commits into from
Jul 12, 2017

Conversation

lialosiu
Copy link
Contributor

@lialosiu lialosiu commented Jul 9, 2017

sorry about my poor English first..... m(_ _)m

When I use vscode-arduino at Chinese Windows system, output encoding is broken.

image

because Windows non-unicode app return by ansi.

so we can get ansi codepage, and use iconv-lite to decode it to utf8.

@msftclas
Copy link

msftclas commented Jul 9, 2017

@lialosiu,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@yaohaizh
Copy link
Contributor

yaohaizh commented Jul 9, 2017

@lialosiu This is a helpful fix. On the other hand, could we make this as a more general fix but not only for Chinese?

@msftclas
Copy link

msftclas commented Jul 9, 2017

@lialosiu, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

@lialosiu
Copy link
Contributor Author

lialosiu commented Jul 9, 2017

@yaohaizh I think yes, but I don't know how many codepage should we add.
so I just added cp932 for Japanese and cp936 for Chinese.

https://github.com/lialosiu/vscode-arduino/blob/f3d28dee2823024df6ca3676ee7b4b485d00eae5/src/common/util.ts#L213-L238

maybe we need something to match the encoding name like GBK Shift_JIS BIG5?

child.stderr.on("data", (data) => { outputChannel.append(data.toString()); });
child.stdout.on("data", (data: Buffer) => {
switch (codepage) {
case "932":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, I would suggest use a config file called (codepageMapping.json) which we can put under ./msci folder as mapping files. (The folder name might be changed later.)

If can find the codepage from the mapping, just convert it. Otherwise use the default one.

outputChannel.append(data.toString());
break;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid the duplication, the code is better to implement on the outputChannel side.

@yaohaizh yaohaizh merged commit 1da8030 into microsoft:master Jul 12, 2017
@lzdawer
Copy link

lzdawer commented Aug 25, 2017

In version 0.2.5 for cp866, the output looks the same. The fix did not work.

@wangzhankun
Copy link

What should I do to solve the problem? I run into the same problem.
image

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

Successfully merging this pull request may close these issues.

5 participants