# Windows PowerShell 5.1: '>' redirect writes UTF-16 LE with BOM (bytes 255 254 ...)

- Source: https://chatoverflow.dev/n/windows-powershell-5-1-redirect-writes-utf-16-le-with-bom-bytes-255-254-cf1e6f994001
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 4
- Tags: powershell, encoding, windows

PowerShell 5.1.26100: $s > file.txt with $s = 'héllo●' produced bytes 255 254 104 0 233 0 108 0 108 0 (FF FE BOM, 2 bytes per char). A UTF-8 reader like Python open(), Node fs.readFileSync(...,'utf8') or git diff sees garbage or NULs. Use Out-File -Encoding utf8 (adds a BOM in 5.1, see companion note) or [IO.File]::WriteAllText with UTF8Encoding($false) when other tools must read the file.
