复制代码
- ::获取字符串的字节数
- ::code by youxi01@cmd_xp
- @echo off
- setlocal enabledelayedexpansion
- if "%1"=="" goto :help
- call :test "%~1"
- echo %1的字节有:%len%
- pause>nul
- :test
- set "var=%~1"
- for /l %%i in (0 1 200) do (
- set "var_=!var:~%%i,1!"
- if "!var_!"=="" goto :eof
- if !var_! gtr Z (set /a len+=2) else set /a len+=1
- )
- goto :eof
- :help
- echo.&echo ==========================求字符串的字节数=================
- echo [使用格式] %~nx0 "字符串"
- echo [使用示例] %~nx0 "好人123"
- echo ============================--------=================================
- cmd /k
[此贴子已经被作者于2007-10-26 14:03:11编辑过]
复制代码
- ::获取字符串的字节数
- ::code by youxi01@cmd_xp
- @echo off
- if "%1"=="/?" goto help
- if "%1"=="" goto :help
- call :test "%~1"
- echo %1的字节有:%len%
- :test
- set "var=%~1"&set len=0
- :lp
- set "var1=%var:~0,1%"
- if %var1% gtr Z (set /a len+=2) else set /a len+=1
- set "var=%var:~1%"
- if defined var goto lp
- goto :eof
- :help
- echo.&echo ==========================求字符串的字节数=================
- echo [使用格式] %~nx0 "字符串"
- echo [使用示例] %~nx0 "好人123"
- echo ============================--------=================================
- cmd /k
复制代码
- ::获取字符串的字节数
- ::code by Defanive
- @echo off
- setlocal enabledelayedexpansion
- if "%1"=="" goto :help
- call :test "%~1"
- echo %1的字节有:%len%
- pause>nul
- :test
- echo."%~1">"%temp%\lb.tmp"
- for /f %%a in ("%temp%\lb.tmp") do set /a len=%%~za-4
- del /f /q "%temp%\lb.tmp"
- goto :eof
- :help
- echo.&echo ==========================求字符串的字节数=================
- echo [使用格式] %~nx0 "字符串"
- echo [使用示例] %~nx0 "好人123"
- echo ============================--------=================================
- cmd /k
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |