批处理简单获取字符串的字节数- ::获取字符串的字节数
- ::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
复制代码
|