Powershell:设置Get-Content管道的编码 [英] Powershell: Setting Encoding for Get-Content Pipeline

查看:702
本文介绍了Powershell:设置Get-Content管道的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  cat tmp.log -encoding UTF8> new.log 

生成的文件仍在UCS-2 Little Endian中。这是因为管道总是以这种格式吗?有没有一个简单的方法来管理这个新文件为UTF8?

解决方案

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


I have a file saved as UCS-2 Little Endian I want to change the encoding so I ran the following code:

cat tmp.log -encoding UTF8 > new.log

The resulting file is still in UCS-2 Little Endian. Is this because the pipeline is always in that format? Is there an easy way to pipe this to a new file as UTF8?

As suggested here:

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

这篇关于Powershell:设置Get-Content管道的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆