Add-Content 输出 ASCII 格式
Out-File 默认输出 Unicode 格式, 可以使用 -Encoding ASCII来指定编码方式。
执行以下命令,然后查看三个文件的格式。
1 Add-Content "D:\testA.txt" "ASCII Format Only"
2
3 Out-File -FilePath "D:\TestB.txt" -Append -InputObject "Default, file format is Unicode"
4
5 Out-File -FilePath "D:\TestC.txt" -Append -Encoding ASCII -InputObject "Now, file format is ASCII."
2
3 Out-File -FilePath "D:\TestB.txt" -Append -InputObject "Default, file format is Unicode"
4
5 Out-File -FilePath "D:\TestC.txt" -Append -Encoding ASCII -InputObject "Now, file format is ASCII."