Re: Hex Conversion to bytes....
Re: Hex Conversion to bytes....
- Subject: Re: Hex Conversion to bytes....
- From: "M. Uli Kusterer" <email@hidden>
- Date: Mon, 29 Nov 2004 18:01:04 +0100
At 18:03 Uhr -0800 28.11.2004, John Draper wrote:
How is the best way to take a series of hex characters like this...
8d6f123e67cd548ca24d2323cd4a6514
Then convert them into 8 bit bytes and place them into an array of
8 bit bytes. I DONT mean a NSArray, but just to place them
into memory, which when dumped, would look like this...
8d 6f 12 3e <etc>
I did the usual searches for "string conversions", "format" and
I don't see any utilities to do this.
Well, I'm just doing it manually:
// Hexadecimal long:
- (IBAction)takeHexLongStringFrom:(id)sender
{
NSString* str = [sender stringValue];
int x, hx = 0;
value = 0;
for( x = [str length] -1; x >= 0; x-- )
{
int currVal = UKHexToDec([str characterAtIndex: x]); //
Turn '1' into 1, 'A' into 10 etc.
value += currVal * pow(16,hx); // Base 16!
hx++;
}
[self refreshDisplay: nil];
}
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden