utf16LE encodes s as UTF-16 little-endian with a BOM, mimicking PowerShell redirection.
(s string)
| 150 | |
| 151 | // utf16LE encodes s as UTF-16 little-endian with a BOM, mimicking PowerShell redirection. |
| 152 | func utf16LE(s string) []byte { |
| 153 | out := make([]byte, 0, 2+2*len(s)) |
| 154 | out = append(out, 0xFF, 0xFE) // LE BOM |
| 155 | for _, r := range s { |
| 156 | out = append(out, byte(r), byte(r>>8)) |
| 157 | } |
| 158 | return out |
| 159 | } |
| 160 | |
| 161 | // utf16BE encodes s as UTF-16 big-endian with a BOM. |
| 162 | func utf16BE(s string) []byte { |