You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Batch中正常打印ASCII艺术避免出现异常符号?

解决批处理打印ASCII艺术乱码(含�字符)问题

原因分析

你的问题核心在于三个点:目标ASCII艺术使用了Unicode扩展字符(如░)、批处理type命令在UTF-8代码页下存在兼容性缺陷、文件编码或终端字体不匹配。

具体解决方案

1. 确保文件编码为UTF-8无BOM

  • 用记事本打开logo.txt,点击「文件」→「另存为」,编码选择UTF-8(注意不是带BOM的UTF-8),覆盖原文件。
  • 若用VS Code等编辑器,直接将文件编码设置为UTF-8(无BOM)后保存。

2. 替换type命令为PowerShell读取

批处理的type命令在代码页65001下对UTF-8字符的解析存在问题,改用PowerShell命令能稳定读取:

for /F "tokens=*" %%G in ('%SystemRoot%\System32\chcp.com') do for %%H in (%%G) do set /A "CodePage=%%H" 2>nul
%SystemRoot%\System32\chcp.com 65001 >nul
powershell -Command "Get-Content 'logo.txt' -Encoding UTF8"
%SystemRoot%\System32\chcp.com %CodePage% >nul

3. 切换终端支持Unicode的字体

如果仍有�字符,需确保命令提示符使用支持扩展Unicode的字体:

  • 右键终端标题栏→「属性」→「字体」,选择Consolas或Lucida Console,点击确定。

备选方案:用PowerShell脚本替代批处理

若批处理限制过多,可直接编写PowerShell脚本(保存为print-logo.ps1):

Get-Content 'logo.txt' -Encoding UTF8

运行时在命令提示符输入:

powershell -ExecutionPolicy Bypass -File print-logo.ps1

内容的提问来源于stack exchange,提问作者Schooi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 19:47:05