操作系统:Windows 7 SP1
我使用以下命令在 cmd.exe
中创建了一个空文本文件:
echo 2> .gitignore
该命令将 std::cerr
(在本例中为空输出)重定向到 .gitignore
文件中。结果文件具有 ANSI
编码,但我需要 UTF-8
。我可以为 >
操作指定必要的编码 (UTF-8
) 吗?
最佳答案
通过批处理文件输出重定向是不可能的。
使用内置实用程序的唯一方法是调用 powershell:
powershell -c "[io.file]::WriteAllText('.gitignore','',[System.Text.Encoding]::UTF8)"
关于windows - 写一个只有 UTF-8 BOM 的空文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31771793/