Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Remove UTF-8 BOM from text files (except PowerShell files)#100

Closed
xtqqczze wants to merge 4 commits into
PowerShell:masterfrom
xtqqczze:strip-bom
Closed

Remove UTF-8 BOM from text files (except PowerShell files)#100
xtqqczze wants to merge 4 commits into
PowerShell:masterfrom
xtqqczze:strip-bom

Conversation

@xtqqczze

Copy link
Copy Markdown
Contributor

@rjmholt

rjmholt commented Aug 29, 2020

Copy link
Copy Markdown
Contributor

Probably best not to remove the BOM from PowerShell scripts. Any script that needs to be run by Windows PowerShell needs a BOM so that WinPS won't try to read it as CP-1252

@xtqqczze

Copy link
Copy Markdown
Contributor Author

@rjmholt The changed *.ps1, *.psd1 scripts are ASCII-safe. A good point that Windows PowerShell defaults to Windows-1252 though. [1]

@rjmholt

rjmholt commented Aug 30, 2020

Copy link
Copy Markdown
Contributor

[1]

Ha, yes, despite the attributions at the top, I wrote that doc

The changed *.ps1, *.psd1 scripts are ASCII-safe

Yes, they are for now, but the issue arises when people edit them

@xtqqczze

xtqqczze commented Aug 30, 2020

Copy link
Copy Markdown
Contributor Author

This repo contains 13 .ps1 files and 14 psd1 files, and 4 psm1 files. Currently only 2 of these files contain the BOM - I will exclude these from this PR.

Maybe we need to consider adding a BOM to the remaining PowerShell files. Alternatively, we could add a test to ensure all PowerShell files are ASCII-safe.

@rjmholt

rjmholt commented Aug 31, 2020

Copy link
Copy Markdown
Contributor

Maybe we need to consider adding a BOM to the remaining PowerShell files. Alternatively, we could add a test to ensure all PowerShell files are ASCII-safe.

Yeah, it sounds like adding the BOM would be a good idea. PSScriptAnalyzer exports this rule to assess scripts' need for a BOM.

@xtqqczze

Copy link
Copy Markdown
Contributor Author

Ah, so that's the purpose of UseBOMForUnicodeEncodedFile 😄

@xtqqczze

Copy link
Copy Markdown
Contributor Author

I think the best approach would be to check the PowerShell files are ASCII-safe with a Github action. However, in the short term, the simplest solution seems to be just to add the BOM to these files.

@xtqqczze xtqqczze changed the title Remove UTF-8 BOM from text files Remove UTF-8 BOM from text files (except PowerShell files) Aug 31, 2020
@xtqqczze

Copy link
Copy Markdown
Contributor Author

@rjmholt This PR is ready for review.

@xtqqczze xtqqczze closed this Jul 5, 2021
@xtqqczze xtqqczze reopened this Jul 5, 2021
@xtqqczze xtqqczze closed this by deleting the head repository Oct 4, 2025
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.

2 participants