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

fix(core): Ensure manipulating config with UTF8 encoding #4644

Merged
merged 5 commits into from
Mar 4, 2022

Conversation

chawyehsu
Copy link
Member

@chawyehsu chawyehsu commented Jan 11, 2022

Description

Use utf8 encoding in scoop's and aria2's config

Motivation and Context

Fixes #4629

How Has This Been Tested?

New unit tests introduced.

Checklist:

  • I have read the Contributing Guide.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

Copy link
Member

@niheaven niheaven left a comment

Choose a reason for hiding this comment

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

Maybe New-Item is another choice.

I found in its docs that: (-ItemType File)

When you create a file using this method, the resulting file is encoded as UTF-8 without a byte-order-mark (BOM).

lib/core.ps1 Outdated Show resolved Hide resolved
lib/core.ps1 Show resolved Hide resolved
Fixes ScoopInstaller#4629

Signed-off-by: Chawye Hsu <chawyehsu@hotmail.com>
Signed-off-by: Chawye Hsu <chawyehsu@hotmail.com>
@chawyehsu
Copy link
Member Author

I've updated the implementation by referring the simpler Puppet.Dsc's implementation and updated the tests. The tests failed under WindowsPowerShell on CI, which can't be reproduced on my local environment.

@niheaven Need your help. You may look at and review the new commits and see if it can be bundled into the upcoming release.

@chawyehsu chawyehsu changed the title fix(core,aria2): Use utf8 encoding in scoop's and aria2's config fix(core): Ensure manipulating config with UTF8 encoding Mar 2, 2022
@niheaven
Copy link
Member

niheaven commented Mar 2, 2022

I'll check it tomorrow.

@niheaven
Copy link
Member

niheaven commented Mar 4, 2022

@chawyehsu It is a bug of Pester/PS5 when test file contains non-ASCII characters. Using [Regex]::Unescape to avoid it.

Although change [System.IO.File]::ReadAllText to [System.IO.File]::ReadAllLines to keep consistence.

@niheaven niheaven marked this pull request as ready for review March 4, 2022 09:48
Copy link
Member Author

@chawyehsu chawyehsu left a comment

Choose a reason for hiding this comment

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

LGTM

@niheaven niheaven merged commit 59328fc into ScoopInstaller:develop Mar 4, 2022
@chawyehsu chawyehsu deleted the fix/unicode-support branch March 9, 2022 06:05
niheaven added a commit that referenced this pull request Aug 21, 2022
This was introduced in #4644 and only occurred in non-Unicode system
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.

None yet

2 participants