gpt4 book ai didi

windows - 写一个只有 UTF-8 BOM 的空文件

转载 作者:可可西里 更新时间:2023-11-01 14:13:35 24 4
gpt4 key购买 nike

操作系统: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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com