China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-02 14:55
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » It is "it is said", "unicode to ANSI batch processing" is "batch processing for converting Unicode to ANSI". So the translation is: It is said batch processing for converting Unicode to ANSI View 2,874 Replies 6
Original Poster Posted 2006-10-23 08:23 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
```
@Echo off
Md temp
For %%a in (*.inf) Do Type %%a >Temp\%%a
Copy Temp\*.inf /y
Del Temp\*.inf
Rd Temp


Converting many *.inf, *.ini, etc. Unicode formats to ANSI can reduce file size without changing functionality!

Everyone, think about it, can we make a registry cleanup based on this principle?

[ Last edited by electronixtar on 2006-10-23 at 08:24 ]
```

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 2 Posted 2006-10-23 08:32 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Can converting Unicode to ANSI format really ensure that the functionality remains unchanged? Although I don't know if it's correct, I have some doubts about this statement. Those who know, please explain the principle.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2006-10-23 08:40 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Because Unicode uses 2 bytes to store English, while ANSI only uses 1 byte. Many inf files in the system are completely sufficient with ANSI.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2008-05-11 13:20 ·  中国 辽宁 锦州 联通
中级用户
★★
Credits 228
Posts 106
Joined 2008-04-26 12:34
18-year member
UID 117003
Gender Male
Status Offline
Bidirectional test of a text,

1. ANSI. The name is RVI.txt, and the content is as follows:

{N=2,300,14}
V1:=((C-O)+2*(REF(C-O,1)+REF(C-O,2)+REF(C-O,3)))/6;
V2:=((H-L)+2*(REF(H-L,1)+REF(H-L,2)+REF(H-L,3)))/6;
NUM:=SUM(V1,N);
DENUM:=SUM(V2,N);
RVI:NUM/DENUM;
RVISIG:(RVI+2*(REF(RVI,1)+REF(RVI,2)+REF(RVI,3)))/6

The test code:

cls
::@Echo off
del /s /q RVI.inf RVI_cheng.inf
echo.
For %%a in (RVI.txt) Do Type %%a >RVI.inf
echo.
For %%a in (RVI.inf) Do Type %%a >RVI_cheng.inf
start RVI.inf
start RVI_cheng.inf
exit

Test results:
RVI.inf - - - UNICODE encoding, normal display.
RVI_cheng.inf - - - ANSI encoding, abnormal character display. As follows:

{ N = 2 , 3 0 0 , 1 4 }

V 1 : = ( ( C - O ) + 2 * ( R E F ( C - O , 1 ) + R E F ( C - O , 2 ) + R E F ( C - O , 3 ) ) ) / 6 ;

V 2 : = ( ( H - L ) + 2 * ( R E F ( H - L , 1 ) + R E F ( H - L , 2 ) + R E F ( H - L , 3 ) ) ) / 6 ;

N U M : = S U M ( V 1 , N ) ;

D E N U M : = S U M ( V 2 , N ) ;

R V I : N U M / D E N U M ;

R V I S I G : ( R V I + 2 * ( R E F ( R V I , 1 ) + R E F ( R V I , 2 ) + R E F ( R V I , 3 ) ) ) / 6


2. UNCODE. The name is RVI_other.txt, and the content remains unchanged.

The test code, except for changing the file name, is the same:
:clss
::@Echo off
del /s /q RVI_other.inf RVI_other_cheng.inf
echo.
For %%a in (RVI_other.txt) Do Type %%a >RVI_other.inf
echo.
For %%a in (RVI_other.inf) Do Type %%a >RVI_other_cheng.inf
start RVI_other.inf
start RVI_other_cheng.inf
exit

Test results:
Generate RVI_other.inf and RVI_other_cheng.inf. Both displays are the same as the original, but both are ANSI encoding.

This test shows that this Type method can indeed cause a change in character encoding, but the mechanism is not clear. Especially in the first test, UNICODE -> ANSI causes abnormal character display, while in the second test, using UNCODE code also displays normally, which is puzzling.

[ Last edited by nipo on 2008-5-11 at 01:40 PM ]
Floor 5 Posted 2008-05-11 14:40 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Can your BAT run normally?
Floor 6 Posted 2008-05-11 18:21 ·  中国 北京 朝阳区 联通
银牌会员
★★★
Credits 1,287
Posts 634
Joined 2007-05-02 15:06
19-year member
UID 87277
Gender Male
From cmd.exe
Status Offline
It can also be done with cmd /a(/u) and it's safe..
Floor 7 Posted 2008-05-11 21:43 ·  中国 辽宁 锦州 联通
中级用户
★★
Credits 228
Posts 106
Joined 2008-04-26 12:34
18-year member
UID 117003
Gender Male
Status Offline
Reply to floor 5:

I am using .cmd and it runs normally.

Reply to floor 6:

Thank you for the tip. I also saw the relevant post and checked cmd/?.

The reason I am interested in the method of this post is not only for encoding conversion but also for its TYPE function. This can at least theoretically confirm that Unicode-encoded files can be operated independently in the DOS environment.

Specifically, I am still a novice in text processing. I hope to attract the attention of all experts to this issue. Let's work together to accelerate the solution of this problem.

This issue is very important for DOS. If the Unicode issue is not solved, it will compress the living space of DOS. Not only in text processing but also in many applications such as the network. Once it is solved, DOS will get a new world.

[ Last edited by nipo on 2008-5-11 at 09:47 PM ]
Forum Jump: