|
本帖最后由 青青草 于 2021-7-18 15:03 编辑
- :Length
- setlocal enabledelayedexpansion
- set "$=!%1!#"
- set "len="&for %%a in (4096 2048 1024 256 128 64 32 16 8 4 2 1) do (if "!$:~%%a,1!" NEQ "" set/a len+=%%a&set "$=!$:~%%a!" &if "!$:~1!"=="" goto ok)
- set "s=!s!fedcba9876543210" &set/a "len+=0x!s:~16,1!"
- :ok
- endlocal&set/a "%2=%len%"&goto:eof
- pause
复制代码 调用- call :Length %1 %2
- rem 第一个参数为字符串,第二个参数为字符串长度。
复制代码
|
|