在 PowerShell 2.0 中将编码设置为 ANSI [英] Set the encoding to ANSI in PowerShell 2.0

查看:43
本文介绍了在 PowerShell 2.0 中将编码设置为 ANSI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Set-Content cmdlet 的参数 -Encoding 将文件的编码设置为 ANSI,我尝试了这个,但没有用:

I want to set the encoding of a file to ANSI using the parameter -Encoding of the Set-Content cmdlet, I tried this one but it didn't work:

Set-Content -LiteralPath "$filePath" -Encoding Default

推荐答案

PowerShell v2 无法识别参数 -Encoding 的参数 Default.使用参数 Ascii 以 ANSI 编码保存文件:

PowerShell v2 doesn't recognize an argument Default for the parameter -Encoding. Use the argument Ascii to save a file with ANSI encoding:

Set-Content -LiteralPath "$filePath" -Encoding Ascii

或完全省略参数(Set-Content 默认为 ANSI 编码):

or omit the parameter entirely (Set-Content defaults to ANSI encoding):

Set-Content -LiteralPath "$filePath"

这篇关于在 PowerShell 2.0 中将编码设置为 ANSI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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