11

Is there a way to change the default encoding of the > operator in powershell? I'd like it to output as ANSI as UTF-8 for my requirements.txt:

pip freeze > requirements.txt
Jeff
  • 4,285
  • 15
  • 63
  • 115

1 Answers1

12
pip freeze | Out-File -Encoding UTF8 requirements.txt

or you can try

pip freeze > iconv -f UTF-8 -t ISO-8859-1 in.txt > out.txt

you can read about iconv

sundar nataraj
  • 8,524
  • 2
  • 34
  • 46
  • @jeff try ISO-8859-1 for that – sundar nataraj Jul 16 '14 at 02:56
  • ut-File : Cannot validate argument on parameter 'Encoding'. The argument "ISO-8859-1" does not belong to the set unknown,string,unicode,bigendianunicode,utf8,utf7,utf32,ascii,default,oem" specified by the ValidateSet attribute. – Jeff Jul 16 '14 at 02:58
  • @Jeff try utf-8-sig this one . i am learning about them . i have searched and saw this more useful link http://stackoverflow.com/questions/8898294/convert-utf-8-with-bom-to-utf-8-with-no-bom-in-python – sundar nataraj Jul 16 '14 at 03:03
  • I don't think it is supported by powershell. – Jeff Jul 16 '14 at 03:04
  • @Jeff then try in python write a python code that converts.use std.in and std.out for this save the result in txt file. – sundar nataraj Jul 16 '14 at 03:05
  • @Jeff some useful links http://stackoverflow.com/questions/76482/powershell-setting-encoding-for-get-content-pipeline – sundar nataraj Jul 16 '14 at 03:17