Add an option to use UTF-8 encoding when running custom scripts on windows #1701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a draft to suggest an enhancement to Calamari.
Currently, the SilentProcessRunner is over-conservative regarding command output encoding and will only use Western OEM encoding (basically only ASCII chars) on windows.
It greatly limits the custom scripting engine, which will emit garbage when running any commands with output in UTF-8 characters (such as emojis in logs or feedback).
Note that I think that this limitation will only apply to Windows, since SilentProcessRunnerResult static ctor will fallback to UTF-8 because of the fail of the native call. So linux will use a recent output rendering and Windows will be stuck forever in DOS OEM encoding.
My suggestion is to add a new parameter to enable UTF-8 Encoding, which will be used only by PowerShellScriptExecutor and DotNetScriptExecutor for compatibility reasons.
Maybe a more defensive option could be to add an option to opt-out (or it) to this feature in the Custom Script step.
Regards,