PowerShell unable to run Unicode files without BOM

A recent change in PrimalScript’s packager converts all files packaged and executed to Unicode files.

If your script is a standard ANSI file it will be converted to Unicode before being packaged. Under normal circumstances you should never see any problem arising from that process except for a little hiccup that we recently encountered.

If you package your script to use the standard powershell.exe, the unpacking into a temporary file omits the BOM (Byte Order Mark), which causes PowerShell to spew random error messages like those seen below:

image

Unicode files are not required to have a BOM, but is does make things easier for some software. Of course we will add the BOM to the temporary files to remedy this, but you may want to remember this little tidbit if you happen to have a Unicode file PowerShell won’t run.

For users using PrimalScript’s packager to create packages for the Windows Script Host (CScript.exe and WScript.exe) this is not an issue. These engines identify Unicode files correctly without the BOM.