Show characters with accents in redirect file (>output.txt)

╄→尐↘猪︶ㄣ 提交于 2019-12-21 05:29:10

问题


example

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

show:

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

instead of:

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

I also tried with chcp 65001 and 1252

Do you know a fix?

Edit:

I use the truetype Lucida fonts, and even if I do type %tmp%\output.tmp it shows the right characters in console, but not in any text editor.

I also tried:

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

and

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

without success


回答1:


You may use the /U switch of cmd.exe in order to output Unicode characters. For example:

cmd /U /C dir > dirInUnicode.txt

However, this switch works on internal commands only, so you must use an auxiliary file in order to convert the output of mode command:

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



回答2:


Use PowerShell instead of DOS as a command line prompt. Its works flawlessly with special characters.

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


来源:https://stackoverflow.com/questions/32999060/show-characters-with-accents-in-redirect-file-output-txt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!