本帖最后由 aloha20200628 于 2025-3-27 17:16 编辑
回复 1# 大地
假设 1.txt 文本文件是 unicode 编码或 utf-8 编码,可用以下的 powershell 转码方法转为系统默认的 ansi(即 gb2312 简中编码)
一。unicode 转为 ansi,存为 test-1.bat 与 1.txt 文件同目录运行@echo off &powershell "$s=(gc 1.txt -raw -enc 'unicode');sc 1.new.txt $s" &pause&exit/bCOPY 二。utf-8 转为 ansi,存为 test-2.bat 与 1.txt 文件同目录运行@echo off &powershell "$s=(gc 1.txt -raw -enc 'utf8');sc 1.new.txt $s" &pause&exit/bCOPY 如果确认 1.txt 文本文件的编码是 unicode(utf-16),亦可试用以下更简单的方法转码为 ansi(即 gb2312 简中编码) | @echo off &chcp 936>nul | | type 1.txt>1.new.txt &pause&exit/bCOPY |
|