我的三个方案都很老实,没有什么出彩的地方(而且还内置了你的函数),但还是贴出来吧...
com 方案:- @echo off
- setlocal enabledelayedexpansion
- set str= ^^!"$%%&'()*+,-./09:;<=>?@AZ[^_`az|}~
- set<nul>$ /p=@!str!
- debug asc.com<%0 >nul 2>nul
- asc<$>ans.txt
- for /f "delims=" %%a in (ans.txt) do set ans=%%a
- echo %ans%
- pause&exit
- e100 B4 08 CD 21 B4 00 BB 64 00 E8 23 00 B3 0A 89 C8
- e110 E8 1C 00 88 CA 80 C2 30 CD 21 B2 20 CD 21 B4 0B
- e120 CD 21 3C 00 75 DA B4 09 BA 43 01 CD 21 CD 20 F6
- e130 F3 88 E1 38 F8 74 0B B7 FF B4 02 88 C2 80 C2 30
- e140 CD 21 C3 0D 0A 24
- rcx
- 46
- w
- q
复制代码 fc 方案- @echo off
- set str=0123_ABCDXYZabcdxyz
- setlocal enabledelayedexpansion
- set<nul>$ /p"=@!str!"
- fc /b $ %comspec%>#
- for /f "eol=F skip=2 tokens=2" %%a in (#) do set "ans=!ans!%%a "
- echo %ans%
- pause
复制代码 纯内部命令方案(0x20~0x7f 范围):- @echo off&setlocal enabledelayedexpansion
- set str= ^^!"$%%&'()*+,-./09:;<=>?@AZ[^_`az|}~
-
- set $=!str!#
- set N=&for %%z in (4096 2048 1024 512 256 128 64 32 16)do if !$:~%%z!. NEQ . set/aN+=%%z&set $=!$:~%%z!
- set $=!$!fedcba9876543210&set/aN+=0x!$:~16,1!-1
-
- set $= ^^!"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^^_`abcdefghijklmnopqrstuvwxyz{|}~
- set "$= !$!"
-
- (for /l %%a in (32 1 127) do (
- for /f "delims=" %%b in (":!$:~%%a,1!") do if "!str%%b=!" neq "!str!" echo %%a !$:~%%a,1!
- ))>#
- set $=
-
- for /l %%a in (0 1 %n%) do (
- for /f "tokens=1,2 delims= " %%b in (#) do (
- if "!str:~%%a,1!"=="%%c" set "ans=!ans!%%b "
- )
- )
- echo %ans%
- pause
复制代码 纯内部命令方案([a-z_A-Z] 范围),结果测试时反而没有前一个方案快:- @echo off
- set str=0123_ABCDXYZabcdxyz
- setlocal enabledelayedexpansion
- set $=!str!
- set N=&for %%z in (4096 2048 1024 512 256 128 64 32 16)do if !$:~%%z!. NEQ . set/aN+=%%z&set $=!$:~%%z!
- set $=!$!fedcba9876543210&set/aN+=0x!$:~16,1!
- set $=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
- (for %%z in ("48 1 57" "65 1 90" "96 1 122") do (
- for /l %%a in (%%~z) do (
- for /f "delims=" %%b in ("!$:~,1!") do (
- if "!str%%b=!" neq "!str!" echo %%a !$:~,1!
- set $=!$:~1!
- )
- )
- ))>#
- set $=
- for /l %%a in (0 1 !n!) do (
- for /f "tokens=1,2 delims= " %%b in (#) do (
- if "!str:~%%a,1!"=="%%c" set "$=!$!%%b "
- )
- )
- set ans=!$:96=95!
- echo %ans%
- pause
复制代码
|