如何在DOS批处理脚本中将sring转换为十六进制?
例如,将“abcd”转换为“61626364”.
因为’a’是0x61 ……
例如,将“abcd”转换为“61626364”.
因为’a’是0x61 ……
我试图从网上找到一个解决方案,但是找不到我的答案.
@echo off setlocal EnableDelayedExpansion rem Store the string in chr.tmp file set /P "=%~1" < NUL > chr.tmp rem Create zero.tmp file with the same number of Ascii zero characters for %%a in (chr.tmp) do fsutil file createnew zero.tmp %%~Za > NUL rem Compare both files with FC /B and get the differences set "hex=" for /F "skip=1 tokens=2" %%a in ('fc /B chr.tmp zero.tmp') do set "hex=!hex!%%a" del chr.tmp zero.tmp echo %hex%
输出示例:
C:\> test.bat abcd 61626364
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。