1819791 Members
3498 Online
109607 Solutions
New Discussion юеВ

hex to ascii converter

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

hex to ascii converter

Hello all,

does anyone know a unix program or code that will convert hex to ascii - this is for a ctree application that reports in hex.

Thanks

Chris.
hello
9 REPLIES 9
Dennis Handly
Acclaimed Contributor

Re: hex to ascii converter

What type of hex? In binary or as ascii strings "0x20"?
lawrenzo_1
Super Advisor

Re: hex to ascii converter

0x20 etc ...
hello
Torsten.
Acclaimed Contributor

Re: hex to ascii converter

A quick internet search willl find everythink you need - c code, shell scripts, perl code and much more ... did you try this?

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Steven Schweda
Honored Contributor

Re: hex to ascii converter

> A quick internet search willl find
> everythink you need [...]

Everything except a clear description of the
problem to be solved.
James R. Ferguson
Acclaimed Contributor
Solution

Re: hex to ascii converter

Hi Chris:

Do you mean this, for example (?):

# perl -e '$num=shift or die;printf "%s\n",chr(hex($num))' 7e
~

# perl -e '$num=shift or die;printf "%s\n",chr(hex($num))' 48
H


Of course, there is always the 'od' (or 'xd') filter!

Regards!

...JRF...
Rita C Workman
Honored Contributor

Re: hex to ascii converter

Here's something simple....you can play with. As JRF says..there's "od & xd"...

#!/usr/bin/ksh
#set -x
# To convert hex to decimal
#
/usr/bin/clear

echo " Convert DECIMAL to HEX utility"
echo ""
echo " I want to convert a decimal value, Enter 1"
echo ""
echo " Exit Enter E,exit,Q,Quit"

read e_code
case "$e_code" in
*Ee|Qq|quit|exit|bye) echo Quitting! See You Later; exit ;;
1)
echo ">>> Enter decimal value: "
read DECV_in
# echo $DECV_in
DECV=`echo "0D$DECV_in=X" | /usr/bin/adb -o`
echo "Decimal value is: $DECV"
echo ""
;;

>>>>AND IT'S COUNTERPART<<<<

#!/usr/bin/ksh
#set -x
# To convert hex to decimal
#
/usr/bin/clear

echo " Convert HEX to DECIMAL utility"
echo ""
echo " I want to convert a hex value, Enter 1"
echo ""
echo " Exit Enter E,exit,Q,Quit"

read e_code
case "$e_code" in
*Ee|Qq|quit|exit|bye) echo Quitting! See You Later; exit ;;
1)
echo ">>> Enter hexidecimal value: "
read HEX
# echo $HEX
DECV=`echo "0X$HEX=D" | /usr/bin/adb -o`
echo "Decimal value is: $DECV"
echo ""
;;

==================

Rgrds,
Rita
lawrenzo_1
Super Advisor

Re: hex to ascii converter

Thanks all,

yes I did check out a google search however I thought I'd give my friends at the ITRC an opportunity to score points ....

I'll take a look.

Chris.
hello
lawrenzo_1
Super Advisor

Re: hex to ascii converter

cheers
hello
Tingli
Esteemed Contributor

Re: hex to ascii converter

If it is 0x, then you can use:
DECIMAL=$(( 16#${HEX#0x} ))