PowerShellscript, bad file encoding conversation

自作多情 提交于 2019-11-29 14:49:52

When you redirect output to a file, Powershell is using Unicode as the default encoding. Instead of using the redirection operator, you can pipe to Out-File with a -Encoding UTF8 switch.

E:\bin\iconv\iconv.exe -f cp1251 -t utf-8 $inFileName | Out-File -FilePath $outFileName -Encoding UTF8

The following TechNet article has more information (equivalent to Get-Help Out-File -full in Powershell v2).

In case it helps your scenario at all, it's worth noting that you can use Powershell to do the encoding conversion also.

Get-Content $inFileName -Encoding ASCII |
Out-File -FilePath $outFileName -Encoding UTF8
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!