The Encoding Accident That Happened During Batch Text Editing, and Recovery via Full Regeneration
PowerShell Encoding Operations
Introduction
When batch-editing blog article Markdown files in Astro using PowerShell, an encoding misconfiguration caused all Japanese characters to become garbled.
This is the screen we were working on.

What Happened
- PowerShell’s
Set-Contentwrites files as UTF-16 LE by default - Astro’s Content Collections expects UTF-8
- As a result, all Japanese characters were corrupted
Recovery Method
All files were restored from the previous Git commit via checkout, then re-applied using [System.IO.File]::WriteAllText with explicit UTF-8 encoding.
We opened each screen — list, featured, ranking, and detail — in order, and visually verified that the Japanese text was displayed correctly.

# Correct approach
[System.IO.File]::WriteAllText($path, $content, [System.Text.Encoding]::UTF8)
What We Learned
Always specify the encoding explicitly when writing files in PowerShell.
Use Set-Content -Encoding UTF8 or [System.IO.File]::WriteAllText with UTF8.