Is there an app/script out there that can convert a series of bytes from hex to dec (if not, is there an easy way to achieve this in the command prompt in a few lines)?
03 01 9d f0 b4 05 01 67 40 20 00 6b ad
There are tons of online converters, like this one: http://home2.paulschou.net/tools/xlate/
.js
script for cscript
:
num = [];
for (i = 0; i < WScript.Arguments.Length; i++) {
arg = WScript.Arguments(i);
num.push(parseInt(arg, 16));
}
WScript.Echo(num.join(" "));
Batch script for cmd.exe
:
@echo off & setlocal
set /a out=0x%1
:loop
if "%~1"=="" goto :end
set /a num=0x%1
set out=%out% %num%
shift
goto :loop
:end
echo.%out%
If all you want is a string of hex to a string of decimal, then this tiny perl program will do it:
#!/usr/bin/perl
while(<>){s/(.\s*.)\s*/hex($1).' '/eg;print;}
input.hex:
68edcdec4e2c8eae8d2c8e2dedcd6e04d2042fedae52ceac04 ccedaecd8c042ccd8c046cedad0e8dac8eac8c048e0dac044a a82889046c0d2c8d8daccdecacc5042bedae4e04ee2dcd046c
./hex2dec.pl < input.hex
It's forgiving about white space in the source and only looks for consecutive pairs of hex digits.
Just modify with sprintf, push, split etc to control output format
If you install perl on windows, then this will work on the command line:
perl -e "while(<>){s/(.\s*.)\s*/hex($1).' '/eg;print;}" < input.hex
Perl is amazing. Noone should be without it!