By default, PowerShell in Windows seems to be outputting UTF-16 (e.g., if I do a simple echo hello > hi.txt, then hi.txt ends up in UTF-16). I know that I can force this to my desired text encoding by instead doing echo hello | out-file -encoding utf8 hi.txt, but what I'd like is for that to just be the default when I use the redirection operator. Is there any way to achieve this?

link|improve this question

80% accept rate
feedback

1 Answer

Not sure if this will do exactly what you're looking for, but you can try setting the environment variable as mentioned here

$OutputEncoding = New-Object -typename System.Text.UTF8Encoding
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.