UTF-8 output from PowerShell

Not an expert on encoding, but after reading these…

  • http://blogs.msdn.com/b/powershell/archive/2006/12/11/outputencoding-to-the-rescue.aspx
  • http://technet.microsoft.com/en-us/library/hh847796.aspx
  • http://www.johndcook.com/blog/2008/08/25/powershell-output-redirection-unicode-or-ascii/

… it seems fairly clear that the $OutputEncoding variable only affects data piped to native applications.

If sending to a file from withing PowerShell, the encoding can be controlled by the -encoding parameter on the out-file cmdlet e.g.

write-output "hello" | out-file "enctest.txt" -encoding utf8

Nothing else you can do on the PowerShell front then, but the following post may well help you:.

  • http://blogs.msdn.com/b/ddietric/archive/2010/11/08/decoding-standard-output-and-standard-error-when-redirecting-to-a-gui-application.aspx

Leave a Comment