batch-file - 在批处理脚本中将 Big Endian 的字符串转换为 Little Endian
问题描述
有没有办法使用批处理脚本命令将 Big Endian 中的给定字符串转换为 Little Endian?例如,给定字符串:9295147A58EACCAA 将其转换为 Int32 little Endian 为:AACCEA587A149592
解决方案
这是更改字符串字符顺序的代码。
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "BytesBE=%~1"
if not defined BytesBE goto :EOF
set "BytesCO=%BytesBE%"
set "BytesLE="
:ChangeOrder
set "BytesLE=%BytesLE%%BytesCO:~-2%"
set "BytesCO=%BytesCO:~0,-2%"
if defined BytesCO goto ChangeOrder
echo Big Endian: %BytesBE%
echo Little Endian: %BytesLE%
endlocal
批处理文件可以使用类似9295147A58EACCAA
命令提示符窗口中的字符串运行,以测试简单循环并查看存储在BytesLE
输入中的生成输出(存储在BytesBE
. 输入字符串长度应该是正确的结果。
要了解使用的命令及其工作原理,请打开命令提示符窗口,在其中执行以下命令,并仔细阅读每个命令显示的所有帮助页面。
echo /?
endlocal /?
goto /?
if /?
set /?
setlocal /?
推荐阅读
- android - Raspbian OS - 类似 Android 的界面
- openssl - 使用 OpenSSL API 如何从签名文件中访问签名者的证书信息?
- oracle - 如何在输出 xml 中显示与提交的报告相关的详细信息?
- sql - SQLite 查询 WHERE 与 OUTER JOIN
- apache - SSL.conf 文件未引用 .htaccess 文件
- flutter - Flutter的Text()小部件中的TextAllCaps?
- python - 查找图的度数时,dict obj没有属性计数
- powerbi - 如何在 Power BI 的表格视觉对象中显示子组总计?
- javascript - 每隔一段时间更新一个 div 的内容
- javascript - 在非 SSL 站点上的剪贴板 API 读/写/粘贴