Skip to content

fix(windows): add UTF-8 BOM to PowerShell scripts#20

Merged
nordicnode merged 1 commit into
mainfrom
fix/issue-19-ps1-utf8-bom
Jun 17, 2026
Merged

fix(windows): add UTF-8 BOM to PowerShell scripts#20
nordicnode merged 1 commit into
mainfrom
fix/issue-19-ps1-utf8-bom

Conversation

@nordicnode

@nordicnode nordicnode commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Fixes #19

PowerShell 5.1 on Windows defaults to the system ANSI codepage when parsing .ps1 files and misreads the UTF-8 multibyte sequences used in the banner (━, ·, ║, etc.). Without a BOM the parser corrupts these bytes, producing cascading parse errors:

Unexpected token '}' in expression or statement.
The string is missing the terminator.
Missing closing '}' in statement block or type definition.

Adding a UTF-8 BOM (EF BB BF) tells PowerShell to decode the file as UTF-8, resolving the parse errors. The reporter confirmed this on Windows 11.

Applied to both setup.ps1 and uninstall.ps1. The file body is unchanged — only the 3-byte BOM was prepended.

Description

Describe your changes and the reasoning behind them.

Related Issue / PR

Fixes # (issue) or relates to # (PR)

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (non-breaking change to README or other docs)
  • Style/Formatting update (non-breaking formatting change)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

  • Run E2E test suite: bash tests/test_e2e.sh
  • Output / Verification details:

Checklist

  • My code follows the style guidelines of this project (run shfmt on shell scripts)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings/errors in the test suite

Summary by CodeRabbit

  • Chores
    • Updated file encoding for PowerShell setup and uninstall scripts. No functional changes to behavior or operations.

Fixes #19

PowerShell 5.1 on Windows defaults to the system ANSI codepage when parsing .ps1 files and misreads the UTF-8 multibyte sequences used in the banner (━, ·, ║, etc.). Without a BOM the parser corrupts these bytes, producing cascading parse errors:

  Unexpected token '}' in expression or statement.
  The string is missing the terminator.
  Missing closing '}' in statement block or type definition.

Adding a UTF-8 BOM (EF BB BF) tells PowerShell to decode the file as UTF-8, resolving the parse errors. The reporter confirmed this on Windows 11.

Applied to both setup.ps1 and uninstall.ps1. The file body is unchanged — only the 3-byte BOM was prepended.
@nordicnode nordicnode merged commit fad1e6b into main Jun 17, 2026
4 of 5 checks passed
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d94b42c0-80da-4ee3-9bdf-58b1be105834

📥 Commits

Reviewing files that changed from the base of the PR and between b86b27f and 4b3e84e.

📒 Files selected for processing (2)
  • setup.ps1
  • uninstall.ps1

📝 Walkthrough

Walkthrough

A leading UTF-8 BOM character is prepended to the first line of both setup.ps1 and uninstall.ps1, changing their encoding from UTF-8 to UTF-8-BOM. No logic, control flow, or API surface is modified.

Changes

PowerShell Script BOM Encoding Fix

Layer / File(s) Summary
BOM prefix added to script headers
setup.ps1, uninstall.ps1
The opening line of each script gains a leading UTF-8 BOM character before <#, re-encoding both files as UTF-8-BOM to resolve PowerShell parsing errors on Windows.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🐇 A tiny byte at the start of the line,
A BOM so small, yet oh so divine,
PowerShell stumbled, then parsed with a cheer,
The scripts now run without error or fear —
One character fixes what logs made unclear! 🎉

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-19-ps1-utf8-bom

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix Windows PowerShell parsing by adding UTF-8 BOM to .ps1 scripts
🐞 Bug fix 🕐 Less than 5 minutes

Grey Divider

Description

• Prepend UTF-8 BOM to PowerShell scripts to force UTF-8 decoding on Windows.
• Prevent PowerShell 5.1 parse errors caused by ANSI codepage mis-decoding of Unicode banners.
• Apply fix consistently to both setup and uninstall entrypoint scripts.
Diagram

graph TD
  U["User"] --> PS["PowerShell 5.1"] --> S1["setup.ps1 (UTF-8 BOM)"]
  PS --> S2["uninstall.ps1 (UTF-8 BOM)"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Remove/replace Unicode banner characters
  • ➕ Avoids encoding sensitivity across older shells/editors
  • ➕ No BOM-related tooling concerns
  • ➖ Degrades UX/readability of script output
  • ➖ Does not address general UTF-8 content in scripts
2. Require PowerShell 7+ (pwsh) on Windows
  • ➕ Modern UTF-8 behavior by default; fewer legacy encoding pitfalls
  • ➖ Raises the minimum requirement and breaks users on stock Windows PowerShell 5.1
  • ➖ Not aligned with a fix intended for Windows 11 default environment

Recommendation: Keep the BOM approach: it is the smallest, most compatible fix for Windows PowerShell 5.1’s default ANSI decoding behavior, and it preserves existing script content/output without changing runtime logic.

Files changed (2) +2 / -2

Bug fix (2) +2 / -2
setup.ps1Prepend UTF-8 BOM to force correct PowerShell decoding +1/-1

Prepend UTF-8 BOM to force correct PowerShell decoding

• Adds a UTF-8 BOM at the start of the file so Windows PowerShell 5.1 decodes the script as UTF-8. This prevents parse errors triggered by mis-decoded multibyte Unicode characters in the banner.

setup.ps1

uninstall.ps1Prepend UTF-8 BOM to force correct PowerShell decoding +1/-1

Prepend UTF-8 BOM to force correct PowerShell decoding

• Adds a UTF-8 BOM at the start of the file so Windows PowerShell 5.1 decodes the script as UTF-8. This avoids parsing failures caused by ANSI codepage interpretation of UTF-8 bytes.

uninstall.ps1

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

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.

Windows PS1 Script

1 participant