Skip to content
HusaynThe Builder’s Lab
  • Home
  • Work
  • Lab
  • Play
  • About
  • Contact
  • CV

Husayn

Builder & researcher · Kano, Nigeria. Building in public, writing down what I learn.

Index

  • Home
  • Work
  • Lab
  • Play
  • About
  • Contact
  • CV

Elsewhere

  • husseinitijani8632@gmail.com
  • GitHub @husaynocean (opens in a new tab)
  • X / Twitter @xyz_husayn (opens in a new tab)
  • LinkedIn in/husseinitijani (opens in a new tab)
© 2026 Hussein TijaniLast updated 29 Oct 2026
0 XP60 fps
The Lab
21 August 2026Note

When PowerShell quietly corrupts your source files

Characters like ₦ and curly quotes turned into garbage after scripted file writes on Windows. Here is the cause, and a one-line fix that has held up since.

Tooling · Lessons from building

While building One Ocean I was writing files from PowerShell scripts and here-strings. Some files came out with mangled characters, such as ₦ where ₦ should be. The next build would fail, or worse, still pass and ship broken copy.

Cause

Windows PowerShell 5.1 does not write plain UTF-8 by default. Depending on the cmdlet you get UTF-16 or the system ANSI code page, and -Encoding UTF8 adds a byte-order mark. Tools that expect clean UTF-8 then misread the file.

Fix

Write through .NET with an explicit UTF-8 encoder that has the BOM turned off:

powershell
$utf8 = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($path, $content, $utf8)
Rule I follow now: if a script writes source code, it states the encoding explicitly.

Related project

One Ocean

Older entry

Building a latency experiment when the fast feeds are geo-blocked