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

Exec task unicode fix #143

Merged
merged 3 commits into from
Aug 13, 2015
Merged

Conversation

AndyGerlicher
Copy link
Contributor

Fixes #142 and probably #104 (thanks @akoeplinger for pointing that out!).

Definitely not an expect on code pages and cmd.exe encoding, but this works better than previously in all the scenarios I tested.

The only remaining encoding issue I found is if the command you run has non-ansi characters (e.g. echo 创建 was the test case I used), it will still show up as ?? on the console. I don't think that can be fixed here though.

- On an OS >= Windows 7 (v6.1), the Exec command will now using UTF-8 (w/o
  BOM) encoding for Console output and writing the temporary .cmd file.
  This will enable non-ansi characters in the Command property to work as
  expected.
- Added a unit test to cover the scenario.
@rainersigwald
Copy link
Member

LGTM.

if (EncodingUtilities.CurrentSystemOemEncoding.CodePage != sw.Encoding.CodePage)
{
// Output to nul so we don't change output and logs.
sw.WriteLine($"chcp {sw.Encoding.CodePage}>nul");
Copy link
Member

Choose a reason for hiding this comment

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

You're using C#6 features here, is the solution already updated to that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, probably best to just not go there at this point. Especially for a single change and I'm not sure what it would do to the xplat / Xamarin Studio story when this gets merged.

@akoeplinger
Copy link
Member

Left some comments, LGTM otherwise (though I'd preferred if the reformatting of the properties etc. were done in a separate commit, so the real change is easier to see).

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

Successfully merging this pull request may close these issues.

Exec task fails with Unicode characters
4 participants