A little proof-of-concept program I put together:
Code: Select all
@echo off & setLocal enableExtensions disableDelayedExpansion
(call;) %= sets errorLevel to 0 =%
for /f "tokens=*" %%A in ('chcp') do for %%B in (%%A) do set "cp=%%~nB"
mode con cp select=437 >nul
((for /l %%I in (1 1 70) do pause) >nul & set /p "tab=") <"%ComSpec%"
set "tab=%tab:~0,1%"
mode con cp select=%cp% >nul
set "sp= "
set "nos=0123456789"
set "UC=ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set "lc=abcdefghijklmnopqrstuvwxyz"
set "printable=!#$%%&'()*+,-./%nos%:;<=>?@%UC%[\]^_`%lc%{|}~"
(for /f useBackq^ delims^="%printable%"^%tab%^%sp% %%A in ("%~1") do goto die
) || echo(no non-printable characters found in file
goto end
:die
echo(non-printable characters found in file
(call) %= sets errorLevel to 1 =%
:end
endLocal & goto :EOF
Just one thing… if someone could tell me how to find the line number where offending characters occur, I’d be extremely grateful!
- SB