in the borders of a box. This is batch only, not hybrid or 3rd party tools.
The project was going well until I tried it on my new Window 10 PC. My forfiles
method of capturing DOS characters into variables has a problem with the lower
ascii codes and displays only a box with a question mark.
In my project I am eliminating certain characters that might be unfriendly, and those
show in the ascii table as blank.
Does anyone have any solution to this issue after upgrading to Windows 10?
Thanks.
Code: Select all
@Echo Off
call :asciiTable
goto :eof
:asciiTable
rem display a table of ascii characters and codes in the range 1-255.
rem problem characters will have a code # but no character and not be available as a border char.
setlocal EnableDelayedExpansion
Call :makeHexString hString
Set "i=1"
For %%a In (%hString%) Do Set "hx[!i!]=0x%%a" & Set /A "i+=1"
Set "idx=0" & Set "idx2=1"
For /L %%n In (1,1,15) Do (
For /L %%r In (1,1,17) Do Set /A "i%%r=%%r+!idx!"
Call Set "str=%%hx[!i1!]%% %%hx[!i2!]%% %%hx[!i3!]%% %%hx[!i4!]%% %%hx[!i5!]%% %%hx[!i6!]%% %%hx[!i7!]%%"
Call Set "str=!str! %%hx[!i8!]%% %%hx[!i9!]%% %%hx[!i10!]%% %%hx[!i11!]%% %%hx[!i12!]%% %%hx[!i13!]%% %%hx[!i14!]%%"
Call Set "str=!str! %%hx[!i15!]%% %%hx[!i16!]%% %%hx[!i17!]%%"
For /F "tokens=1-17" %%a In (
'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(!str!"') Do (
Set "char[!i1!]=%%a" & Set "char[!i2!]=%%b" & Set "char[!i3!]=%%c" & Set "char[!i4!]=%%d" & Set "char[!i5!]=%%e"
Set "char[!i6!]=%%f" & Set "char[!i7!]=%%g" & Set "char[!i8!]=%%h" & Set "char[!i9!]=%%i" & Set "char[!i10!]=%%j"
Set "char[!i11!]=%%k" & Set "char[!i12!]=%%l" & Set "char[!i13!]=%%m" & Set "char[!i14!]=%%n" & Set "char[!i15!]=%%o"
Set "char[!i16!]=%%p" & Set "char[!i17!]=%%q"
)
Set /A "idx+=17"
)
rem special handling of ascii code #17
For /F "tokens=1" %%a In (
'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0xff!"') Do Set "chr255=%%a")
Set "char[17]=!char[17]!%chr255%"
Set "c=1"
Set "counter=17"
> "asciiTbl.txt" (
Echo BoxTool Border Friendly ASCII Codes ^& Characters
For /L %%i In (1,1,15) Do (
Set "numbs="
For /L %%n In (!c!,1,!counter!) Do (
Set "str= %%n %"
Set "str=!str:~-5!"
Set "numbs=!numbs!!str!")
For /L %%t In (!c!,1,!counter!) Do (
Set "xCode="
For %%x In (7 8 9 10 13) Do If %%x==%%t Set "xCode=True"
Set "s=%%t" & Set /A "s-=1"
Set /A "s=!s!%%17+1"
Set "c!s!=!char[%%t]!"
)
Echo !numbs!
Set "parms= !c1! !c2! !c3! !c4! !c5!"
Set "parms=!parms! !c6! !c7! !c8! !c9! !c10! !c11! "
Set "parms=!parms! !c12! !c13! !c14! !c15! !c16! !c17!"
For /F "tokens=*" %%t in ("!parms!") Do Echo %%t
Set /A "counter+=17"
Set /A "c=!counter!-16")
)
type asciiTbl.txt
endlocal & exit /b
:makeHexString [ret var: string of hex #s for the decimal range 1-255]
setlocal EnableDelayedExpansion
Set "string=0 1 2 3 4 5 6 7 8 9 A B C D E F"
Set "string2=%string: =%"
Set "i=0"
For %%a In (%string%) Do (
For /L %%n In (0,1,15) Do (
Set "x=!string2:~%%n,1!"
Set "hex[!i!]=%%a!x!"
Set /A "i+=1"
))
rem exclude 14 characters that can be a problem manipulating and echoing:
For %%n In (7 8 9 10 13 26 32 33 38 59 60 62 94 124) Do Set "hex[%%n]=FF"
rem prepare returned string from the array
Set "hexStr="
For /L %%n In (1,1,255) Do Set "hexStr=!hexStr! !hex[%%n]!"
endlocal & Set "%~1=%hexStr:~1%" & exit /b
edited 3/1/17 - missing end quote Set "i=0"