I'm a little confused:
>I have to convert a string in to a hex
- convert a string of numbers? into a string of Hex numbers?

>so the return would be something like this:"255 161 35 210 94..."
But this implies you convert a string of Hex numbers into a single string of
decimal numbers

Which is it?

Aaron's suggestion works if you have the numbers as integers and write them
to a string.

If I assume you have a string of hex numbers and wish to convert to a string
of decimal numbers without white spaces you could try:

// assuming cpIn is the string with the Hex, cpOut is the output string with
enough memory allocated to hold the output plus NULL.

int iLength = StrLen(cpIn);

for(int i=0;i<iLength;i += 3)
{
    int iTemp;
    char cpTemp [4];

    iTemp = (HEXtoDec(cpIn[i]) * 0x10) & 0xFF:
    iTemp += HEXtoDec(cpIn[i+1]) & 0xFF;
    StrPrintF(cpTemp, "%d", iTemp);
    StrCat(cpOut,cpTemp);
}

You need to write HEXtoDec to convert a single character to the proper
decimal value.  Just use a simple case statement.
This is off the top of my head, I'm sure I made an error or two.

----- Original Message -----
From: "borjas" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Wednesday, April 02, 2003 8:48 AM
Subject: String to Hex


> Hi,
> I'm developing a little aplication for Palm. Now I'm facing a little
> problem. I have to convert a string in to a hex and I don't now how.
> The string would be like this:"FF A1 23 D2 5E....". First I have to take
> out all of the spaces. I tried to use StrCopy but I got no sucess. After
> taking the space I sould convert it into hex. The convertion sould be 2
> by 2 so the return would be something like this:"255 161 35 210
> 94..."(without the spaces). I would be verry glad if some one could help
> me.
>
> Thank You
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to