本帖最后由 plp626 于 2011-6-15 19:17 编辑
- ::获取控制符的gbk2unicode方案
- ::以回车符为例演示如下(“名”--unicode编码为540d)
- @ECHO off&setlocal EnableDelayedExpansion
- for /f %%a in ('cmd/u/cecho 名')do set un=%%a
- :: 获取回车符0x0D并存放在变量$0d中
- Set $0d=!un:~0,1!
- Set test=abcd!$0d!##
- ECHO !test!
- set test>$0d.txt
- start $0d.txt
- pause
复制代码
- ::获取unicode文件头的gbk2unicode方案及其测试代码:
- @ECHO off&setlocal EnableDelayedExpansion
- Set gbk=绿图
- chcp 437>nul
- for /f %%a in ('cmd/u/cecho !gbk!')do set un=%%a
- ::获取unicode文件头字符0xFF 0xFE,并存放在变量head中
- Set head=!un:~0,1!!un:~2,1!
- Set head
- set/p=!head!`O}Y<nul>$tmp.txt
- ::"你好" 对应的unicode编码为4f60 597d
- start $tmp.txt
- pause
复制代码 下面列出常用汉字unicode编码的低位值供查阅:复制代码 |