【问题标题】:Show characters with accents in redirect file (>output.txt)在重定向文件 (>output.txt) 中显示带重音符号的字符
【发布时间】:2015-10-07 17:46:59
【问题描述】:

例子

mode con: cp>%tmp%\output.tmp
notepad %tmp%\output.tmp

显示:

Statut du p‚riph‚rique CON:
---------------------------
    Page de codesÿ:   850

代替:

Statut du périphérique CON:
---------------------------
    Page de codes :   850

我也试过chcp 650011252

你知道解决办法吗?

编辑:

我使用 truetype Lucida 字体,即使我使用type %tmp%\output.tmp,它也会在控制台中显示正确的字符,但在任何文本编辑器中都不会。

我也试过了:

cmd /U /C "chcp 65001>nul &mode con: cp>%tmp%\output.tmp"

cmd /A /C "chcp 65001>nul &mode con: cp>%tmp%\output.tmp"

没有成功

【问题讨论】:

标签: windows batch-file cmd console-output


【解决方案1】:

您可以使用cmd.exe 的/U 开关来输出Unicode 字符。例如:

cmd /U /C dir > dirInUnicode.txt

但是,此开关仅适用于内部命令,因此您必须使用辅助文件才能转换 mode 命令的输出:

mode con: cp>%tmp%\output1.tmp
cmd /U /C type %tmp%\output1.tmp > %tmp%\output2.tmp

【讨论】:

  • 非英语控制台示例:netsh advfirewall show current state>%tmp%\tmp.tmp &cmd /U /C "type %tmp%\tmp.tmp>%tmp%\tmp2.tmp" &notepad %tmp%\tmp2.tmp
【解决方案2】:

使用 PowerShell 而不是 DOS 作为命令行提示符。它与特殊字符完美结合。

C:> powershell
PS C:> mode con: cp > temp.txt
PS C:> notepad temp.txt

【讨论】:

    猜你喜欢
    • 2011-08-29
    • 2012-05-13
    • 2018-12-11
    • 2015-01-09
    • 2012-06-21
    • 1970-01-01
    • 2014-06-01
    • 2019-12-28
    • 2011-07-18
    相关资源
    最近更新 更多