{
  "id": 14335800,
  "title": "PowerShell on Legacy Chinese Windows: UTF-8 with BOM or Bust",
  "url": "https://urgent.news/2026/10/14/powershell-on-legacy-chinese-windows-utf-8-with-bom-or-bust",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-14T01:01:34.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mattleeee/powershell-on-legacy-chinese-windows-utf-8-with-bom-or-bust-4g5b"
  },
  "original_language": "en",
  "account": "Windows PowerShell 5.1 does not automatically detect file encodings. When loading a .ps1 file, it looks for a byte-order mark. If present, PowerShell decodes the file accordingly. Without a BOM, it defaults to the system's ANSI code page. On Chinese Windows installations, this code page is GBK (CP936). As a result, non-ASCII characters in the script are decoded through the wrong table, causing mojibake that does not generate an error. The issue led to a week of debugging after a deployment script created directories with incorrect names due to the misinterpretation of characters. The key to resolving the problem is ensuring all .ps1 files are saved as UTF-8 with a BOM and CRLF endings. Identifying the issue involves checking the first bytes of the file; a BOM like EF BB BF indicates UTF-8 with a BOM, while PowerShell 5.1 falls back to the ANSI code page without one.",
  "summary": "Windows PowerShell 5.1 does not guess encodings. When it loads a .ps1 file, it looks for a byte-order mark. If it finds one, it decodes accordingly. If it does not, it falls back to the system's ANSI code page — and on a Chinese Windows install, that code page is GBK (CP936). Every non-ASCII character in your script is then decoded through the wrong table, and you get mojibake that does not throw…",
  "key_points": [
    "PowerShell 5.1 fails to auto-detect file encodings",
    "Chinese Windows uses GBK code page (CP936) by default",
    "Fix involves saving .ps1 files as UTF-8 with BOM"
  ],
  "editors_take": "Relying on byte-order marks for script encoding forces developers to abandon standard UTF-8 defaults to prevent silent character corruption on legacy Chinese Windows systems.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}