Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ascii to hex

351 views
Skip to first unread message

Petr Laznovsky

unread,
Jun 18, 2011, 6:29:33 PM6/18/11
to
Need to convert ascii string into hex in batch, do you have idea?

L.

foxidrive

unread,
Jun 18, 2011, 9:11:10 PM6/18/11
to
On 19/06/2011 08:29, Petr Laznovsky wrote:
> Need to convert ascii string into hex in batch, do you have idea?
>
> L.

:: ASCII to HEX - technique from Tom Lavedas
@echo off
setlocal
set "str=%~1"
if not defined str goto :EOF
:loop
set "substr=%str:~0,8%"
set "str=%str:~8%"
for /f "tokens=2-9" %%a in (
'^(echo.f100 l07 0^&echo.e100 "%substr%"^&echo.d100
107^&echo.q^)^|debug^|find ":"'
) do set hex=%hex% %%a %%b %%c %%d %%e %%f %%g %%h
if not "%str%"=="" goto :loop
set hex=%hex: 00=%
set hex=%hex:~1%
echo.HEX: [%hex%]
pause

0 new messages