Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi friends,
I was working on aprogram that takes 16 Hex characters and converts to 8-ascii characters
the program generates large numbers which are in bytes, but somehow I cannot change to correponding Ascii characters. it generates
numbers such 166,239... numbers less than 255.the function calls Convert() which returns the decimal of hex character
Can anyone help me how I can achieve the desired Ascii chars ? the code is commented to be able to read.
I am really in need for help to get this wright.
Thanks in advance.
/* prtotypes */
typedef unsigned char ByteType ;
int Convert(ByteType val );ByteType ASCIZ(ByteType *Addr);
ByteType ASCIZ(ByteType *Addr)
{
int i, v1, v2;
ByteType a1, a2, v,y;
/* Convert 16-HEXA-character key to be 8-ASCII-character key. */
for (i = 0; i < 8; i++)
{
a1 = *Addr++;
if (i == 7)
a2 = *Addr;
else
a2 = *Addr++;
/* Convert two HEXA characters into their decimal value. */
v1 = Convert(a1);
v2 = Convert(a2);
/* Convert the two decimal value to be one ASCII character. */
v = ((v1 * 16) + v2);
}
return v;
}

The ASCII range is from 0 to 127, of which 0 to 31 and 127 are non printing characters, well sort of.
Problem 1: how are you intending to represent a character over 128 unless you go for an extended character set. I don't know if there is a standard extension.
Problem 2: if you are printing them, how are you going to print the non-printable characters. Are you printing them?
You could go for the uuencode type strategy which restricts the set. The result of this is that you will need more than 8 chars for 16 digits.

![]() |
Asp session
|
how to convert .cgi into ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |