将内容重定向到 ascii 编码的文件
Redirect content to a file in ascii encoding
我们从 PowerShell 运行ning lessc
是这样的:
lessc -x style.less > style.min.css
不幸的是,style.min.css
文件在 unicode
中,而我们希望它在 ascii
中。当从 PowerShell 将结果写入文件时,我们如何强制使用该编码?
有趣的是,当我们 运行 来自 vanilla 命令提示符的相同命令时,编码是 ascii
。
作为一个简单的解决方法,将输出指定为 command-line parameter 而不是重定向标准输出:
lessc -x style.less style.min.css
about_Redirection 关于 PowerShell 重定向的说法。
When you are writing to files, the redirection operators use Unicode encoding... To redirect content to non-Unicode files, use the Out-File cmdlet with its Encoding parameter.
Out-File 有效:
lessc -x style.less | Out-File style.min.css -Encoding ascii
我们从 PowerShell 运行ning lessc
是这样的:
lessc -x style.less > style.min.css
不幸的是,style.min.css
文件在 unicode
中,而我们希望它在 ascii
中。当从 PowerShell 将结果写入文件时,我们如何强制使用该编码?
有趣的是,当我们 运行 来自 vanilla 命令提示符的相同命令时,编码是 ascii
。
作为一个简单的解决方法,将输出指定为 command-line parameter 而不是重定向标准输出:
lessc -x style.less style.min.css
about_Redirection 关于 PowerShell 重定向的说法。
When you are writing to files, the redirection operators use Unicode encoding... To redirect content to non-Unicode files, use the Out-File cmdlet with its Encoding parameter.
Out-File 有效:
lessc -x style.less | Out-File style.min.css -Encoding ascii