Skip to main content
 首页 » 编程设计

encoding之Powershell:设置获取内容管道的编码

2024年06月20日39xing901022

我有一个保存为 UCS-2 Little Endian 的文件,我想更改编码,因此运行了以下代码:

cat tmp.log -encoding UTF8 > new.log 

生成的文件仍采用 UCS-2 Little Endian。这是因为管道始终采用这种格式吗?有没有一种简单的方法可以将其作为 UTF8 传输到新文件?

请您参考如下方法:

按照建议here :

Get-Content tmp.log | Out-File -Encoding UTF8 new.log