Convert Hex - KSH

Hello,

I woild like to convert hex on KSH not BASH:

I tried to use:

tmp=31
printf "\x"${tmp}""

it works on bash - Output is '1' but not on ksh.

please advice on the right syntax.

Thanks.

$ printf "%x\n" ${tmp}
1f

Should work on ksh/bash

Thank for the quick reply.
The correct output should be 1 not 1f since 31 in hex = 1
Maby I wasnt clear before:
I want to convert from hex to char (ascii table) - and 31 (hex)= 1(char).

Method using "bc" to first convert from Hex to Octal, the using "echo" to convert from Octal to Character.
The "cat -v" is just to avoid displaying real control codes.

while true
do
        echo "Enter Hex character: \c";read HEX
        if [ "${HEX}""X" = "X" ]
        then
                break
        fi
        HEX=`echo "${HEX}"|tr [a-z] [A-Z]`
        OCT=`echo "obase=8;ibase=16;${HEX}"|bc`
        CHAR=`echo "\0${OCT}"`
        echo "${HEX}=${CHAR}"|cat -v
done

Thanks!!!!!!
it works!!