phycool-windows-ps-encoding

Enforces UTF-8 encoding rules for PowerShell 5.1 scripts on Traditional Chinese Windows.

10|3|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill phycool-windows-ps-encoding-cynthia1070711
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: phycool-windows-ps-encoding
Source: https://github.com/Cynthia1070711/PHYCOOL_Tools/tree/main/config-templates/claude/skills/phycool-windows-ps-encoding
Command: npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill phycool-windows-ps-encoding-cynthia1070711

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? On Windows 11 with Traditional Chinese locale (CP950/Big5), PowerShell 5.1 silently corrupts Chinese text: scripts saved without BOM fail to dot-source, console output shows ??, JSON IPC breaks, and Start-Process truncates Chinese arguments. This Skill provides a complete set of defensive encoding rules to eliminate mojibake and silent failures. ## Core Features & Use Cases - Mandatory Script Header: A three-line UTF-8 initialization block placed after param(), plus UTF-8 with BOM file saving so PS 5.1 parses scripts correctly. - Safe File I/O Helpers: Read-Utf8File, Write-Utf8File, Read-JsonFile, and Write-JsonFile replace Get-Content/Set-Content to avoid Big5 misreads and JSON BOM errors. - IPC and Process Safety: Correct Stop Hook stdin reading via [Console]::In.ReadToEnd(), and passing long Chinese prompts to the Claude CLI through @tempfile instead of Win32 ANSI arguments. - Dangerous Character Blacklist: Replacements for em dash, box-drawing characters, curly quotes, and full-width spaces that Big5 cannot represent, enforced by a CI guard script. - Use Case: When writing or reviewing any .ps1 in the party-to-pipeline (orchestrator, workers, shared-utils, stop-report), apply this Skill so Chinese log output, JSON task files, and spawned Claude processes all handle UTF-8 correctly. ## Quick Start Ask the AI to review your PowerShell script for Windows Traditional Chinese encoding issues and apply the UTF-8 header, safe file I/O helpers, and dangerous character replacements.

Frequently Asked Questions about phycool-windows-ps-encoding

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Chinese characters showing as ?? in PowerShell 5.1 output?

Set [Console]::OutputEncoding and [Console]::InputEncoding to [System.Text.Encoding]::UTF8 at the top of your script, right after the param() block. Also set $PSDefaultParameterValues['*:Encoding'] = 'utf8' so file cmdlets default to UTF-8.

Why does my PowerShell script with Chinese text fail to dot-source?

PowerShell 5.1 interprets UTF-8 files without BOM as Big5 (CP950), so Chinese characters corrupt and functions silently fail to load. Save the .ps1 file as UTF-8 with BOM, selectable in the VS Code status bar.

How do I pass long Chinese prompts to Start-Process without truncation?

Start-Process uses the Win32 ANSI API, which truncates or corrupts long Chinese arguments. Write the prompt to a temporary UTF-8 file without BOM and pass it using the Claude CLI @filepath syntax instead.

Should JSON files be saved with or without BOM for ConvertFrom-Json?

JSON files should be saved as UTF-8 without BOM, because ConvertFrom-Json and other tools may fail on a BOM. Use [System.IO.File]::WriteAllText with UTF8Encoding($false) instead of Set-Content -Encoding UTF8, which adds a BOM.

Does this encoding guidance apply to PowerShell 7 or macOS and Linux?

No. PowerShell 7+ defaults to UTF-8 without BOM and behaves differently, and macOS/Linux do not use the CP950 code page. The rules target Windows PowerShell 5.1 only, enforced with #Requires -Version 5.1.

Which characters are forbidden in Big5-locale PowerShell scripts?

Em dash (U+2014), box-drawing characters (U+2500-257F), full-width quotes (U+300C-300F), and full-width spaces (U+3000) are not supported by Big5. Replace them with ASCII equivalents like -, =, |, and regular quotes.