|
本帖最后由 dos时代菜鸟 于 2022-5-19 12:26 编辑
- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- set file1=test.txt
- set "string1=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$*()_+`-=,.?/;"'{}[]\^|^<^>^&%%^^^^ "
- for /f "delims=" %%c in ('type !file1!') do (
- call :str_x "%%c"
- if !found0! EQU 1 ECHO "%%c"
- )
- pause
- goto :eof
- :str_x
- set "str1=%~1"
- SET found0=0
- for /l %%i in (0,1,255) do (
- set ch=!str1:~%%i,1!
- if not "!ch!"=="" (
- set found1=0
- for /l %%n in (0,1,92) do (
- if "!ch!"=="!string1:~%%n,1!" set /a found1 +=1
- )
- if !found1! EQU 0 (
- set found0=1
- exit /b
- )
- ) else (exit /b)
- )
- exit /b
复制代码
先做个字典包含 键盘常规字符,然后 ,读取文件每一行,逐行逐字符判断,如果该字符不在 字典中,就判定为 中文。假定 文件每行最多 256个字符。
|
|