PowerShell UTF-16


I frequently use PowerShell scripts, from different sources - alot of the time originally created in PowerShell ISE or Visual Studio.

When I open them in Atom, however, it does not correctly set the encoding (it still assumes UTF-8). When I change the encoding to UTF-16 BE, it displays fine.

So I guess the issue is either PowerShell scripts don’t implement UTF-16 BE correctly, or Atom is not correctly identifying the encoding.

Happy to provide screenshots or sample files, just let me know what you would need to help resolve.



After testing auto detect, when I select “Auto Detect,” it does correctly select UTF-16 BE. How can I make it automatically do this when PowerShell files are opened?

PS: I want to keep UTF-8 as default (that is indeed what most files are). Maybe we can set default encoding to Auto Detect?


Maybe Scoped Settings is the solution?


Relevant issue:


Yeah, if I could specify I want .ps1 files to be UTF-16 BE that would be great.
Now I know what I’ll be working on in the weekend. :smile:


Ok, I have created a package which allows you to specify a default encoding using a scope selector.

The package is called default-encoding, available here:

I have included a screenshot of an example config to default PowerShell files to use UTF16 BE (my original issue).

Enjoy :smile:


I also updated the package to try to autodetect the encoding if no default config is found.