powershell-utf8-fixer
π―Skillfrom mineru98/skills-store
Detects and automatically fixes PowerShell script encoding issues, ensuring correct display of non-ASCII characters like Korean text and emojis on Windows.
Installation
npx skills add https://github.com/mineru98/skills-store --skill powershell-utf8-fixerSkill Details
Detect and fix PowerShell script encoding issues that cause Korean and other non-ASCII characters to display incorrectly on Windows. Use when (1) PowerShell scripts display garbled Korean/non-ASCII text, (2) creating new .ps1 files with non-ASCII content, (3) validating encoding before committing PowerShell scripts, or (4) troubleshooting character display issues in PowerShell output.
Overview
# PowerShell UTF-8 Fixer
Problem
PowerShell on Windows requires UTF-8 with BOM encoding for scripts containing non-ASCII characters (Korean, Chinese, Japanese, emoji, etc.). Without the BOM (Byte Order Mark), PowerShell interprets the file using the system's default encoding (typically CP949 on Korean Windows), causing character display issues.
Symptoms:
- Korean text appears as
???or garbled characters - Emoji and special characters don't display correctly
Write-Hostoutput shows corrupted text- One script works fine while another with identical code shows garbled text
Root cause: File encoding mismatch
- β UTF-8 with BOM (EF BB BF): PowerShell reads correctly
- β UTF-8 without BOM: PowerShell uses system default encoding β garbled text
Quick Fix
When encountering encoding issues in PowerShell scripts:
- Check encoding:
```bash
node scripts/check_powershell_encoding.js
# Or with npm:
npm run check
```
- Fix encoding:
```bash
node scripts/fix_powershell_encoding.js
# Or with npm:
npm run fix
```
Workflow
When Creating New PowerShell Scripts
After creating any .ps1 file with non-ASCII characters:
```bash
node scripts/fix_powershell_encoding.js script.ps1
```
This ensures the file is saved with UTF-8 BOM from the start.
When Diagnosing Display Issues
If a PowerShell script shows garbled text:
- Check the encoding:
```bash
node scripts/check_powershell_encoding.js problematic_script.ps1
```
- If it shows "UTF-8 without BOM", fix it:
```bash
node scripts/fix_powershell_encoding.js problematic_script.ps1
```
- Test the script again - text should now display correctly
Batch Processing
To check/fix all PowerShell scripts in a directory:
```bash
# Check all scripts
node scripts/check_powershell_encoding.js scripts/windows/
# Fix all scripts that need it
node scripts/fix_powershell_encoding.js scripts/windows/
```
Prevention
To prevent encoding issues in the future:
- Before committing: Run the checker on modified
.ps1files - In CI/CD: Add encoding validation to your pipeline
- Editor settings: Configure your editor to save
.ps1files as UTF-8 with BOM
Editor Configuration Examples
VS Code (settings.json):
```json
{
"[powershell]": {
"files.encoding": "utf8bom"
}
}
```
Cursor (settings.json):
```json
{
"[powershell]": {
"files.encoding": "utf8bom"
}
}
```
Scripts
check_powershell_encoding.js
Diagnoses encoding issues without modifying files.
Usage:
```bash
node scripts/check_powershell_encoding.js
```
Output:
- β UTF-8 with BOM: File is correctly encoded
- β UTF-8 without BOM: File needs fixing
- β UTF-16: File uses UTF-16 encoding
- β Unknown: Unable to detect encoding
Exit codes:
- 0: All files have UTF-8 BOM
- 1: Some files need fixing or have errors
fix_powershell_encoding.js
Adds UTF-8 BOM to PowerShell files that don't have it.
Usage:
```bash
node scripts/fix_powershell_encoding.js
```
Behavior:
- Reads file content as UTF-8
- Writes back with UTF-8 BOM (utf-8-sig)
- Skips files that already have UTF-8 BOM
- Processes
.ps1files recursively in directories
Exit codes:
- 0: All files processed successfully
- 1: Errors occurred during processing
Technical Details
UTF-8 BOM: The byte sequence EF BB BF at the start of a file signals UTF-8 encoding to PowerShell and other Windows applications.
Why PowerShell needs BOM:
- Without BOM, PowerShell uses
[Console]::OutputEncoding(often CP949/CP1252) - With BOM, PowerShell correctly identifies the file as UTF-8
- This is specific to Windows PowerShell's file reading behavior
Alternative workarounds (not recommended):
- Adding encoding commands to each script (verbose, error-prone)
- Using
-Encoding UTF8parameters (doesn't help with file reading) - Avoiding non-ASCII characters (limits usability)
The proper solution is to save files with UTF-8 BOM.
More from this repository7
explaining-code skill from mineru98/skills-store
frontend-design-patterns skill from mineru98/skills-store
Transforms frontend UI/UX by automatically modifying styling, layout, components, and responsive designs using Gemini CLI in --yolo mode.
logic-master skill from mineru98/skills-store
Analyzes Excel files to detect data quality issues, format inconsistencies, and generate comprehensive statistical reports with actionable insights.
commands-creator skill from mineru98/skills-store
Guides creating specialized Claude subagents for targeted, efficient task delegation across different domains. ``` Generates specialized subagents for precise, domain-specific task delegation and ...