Skip to content

Add pre-commit or CI step to enforce UTF-8 BOM encoding on source files #230

@MariusStorhaug

Description

Context

PowerShell source files in a repository may have inconsistent file encodings. If files are not uniformly UTF-8 with BOM, it can cause issues with special characters, tests, or module loading.

Request

A pre-commit or CI step should ensure all relevant source files (.ps1, .psm1, .psd1, etc.) are encoded as UTF-8 with BOM before changes are pushed. This prevents encoding inconsistencies from being introduced into the repository.

What is expected

  • All PowerShell source files are validated and/or converted to UTF-8 with BOM encoding
  • The check runs automatically (pre-commit hook or CI step)
  • Developers are informed when files with incorrect encoding are detected

Acceptance criteria

  • An automated step validates file encoding before code enters the repository
  • Files with incorrect encoding are either auto-converted or flagged for the developer
  • The solution works cross-platform (Windows, macOS, Linux)

Technical decisions

To be determined during implementation planning — evaluate pre-commit hook vs. CI step vs. build-time conversion.


Implementation plan

  • Decide on enforcement mechanism: pre-commit hook, CI check, or build step
  • Implement encoding validation/conversion for .ps1, .psm1, .psd1 files
  • Integrate into the appropriate workflow stage
  • Test with files containing special characters to verify correctness

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions