{"record":{"id":"761632ff7d9245bb","repo":"Fission-AI/OpenSpec","slug":"file-is-encoded-as-utf-16-be-which-is-not-supporte","errorCode":null,"errorMessage":"File is encoded as UTF-16 BE which is not supported. Please re-save as UTF-8 or UTF-16 LE, then retry.","messagePattern":"File is encoded as UTF-16 BE which is not supported\\. Please re-save as UTF-8 or UTF-16 LE, then retry\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/completions/installers/powershell-installer.ts","lineNumber":37,"sourceCode":"    end: '# OPENSPEC:END',\n  };\n\n  constructor(homeDir: string = os.homedir()) {\n    this.homeDir = homeDir;\n  }\n\n  /**\n   * Detect the encoding of a file by inspecting its BOM (Byte Order Mark).\n   * Returns the Node.js BufferEncoding and the raw BOM bytes to preserve on write.\n   */\n  private detectEncoding(buffer: Buffer): { encoding: BufferEncoding; bom: Buffer } {\n    // UTF-16 LE BOM: FF FE\n    if (buffer.length >= 2 && buffer[0] === 0xff && buffer[1] === 0xfe) {\n      return { encoding: 'utf16le', bom: Buffer.from([0xff, 0xfe]) };\n    }\n    // UTF-16 BE BOM: FE FF — not natively supported by Node\n    if (buffer.length >= 2 && buffer[0] === 0xfe && buffer[1] === 0xff) {\n      throw new Error(\n        'File is encoded as UTF-16 BE which is not supported. ' +\n          'Please re-save as UTF-8 or UTF-16 LE, then retry.',\n      );\n    }\n    // UTF-8 BOM: EF BB BF\n    if (buffer.length >= 3 && buffer[0] === 0xef && buffer[1] === 0xbb && buffer[2] === 0xbf) {\n      return { encoding: 'utf-8', bom: Buffer.from([0xef, 0xbb, 0xbf]) };\n    }\n    // No BOM → default UTF-8\n    return { encoding: 'utf-8', bom: Buffer.alloc(0) };\n  }\n\n  /**\n   * Read a profile file, preserving its encoding metadata for round-trip writes.\n   * Throws if the file uses UTF-16 BE (unsupported by Node).\n   */\n  private async readProfileFile(filePath: string): Promise<{ content: string; encoding: BufferEncoding; bom: Buffer }> {\n    const raw = await fs.readFile(filePath);","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/completions/installers/powershell-installer.ts#L19-L55","documentation":"Error \"File is encoded as UTF-16 BE which is not supported. Please re-save as UTF-8 or UTF-16 LE, then retry.\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/core/completions/installers/powershell-installer.ts:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}