Reading Hex from a file
Reading Hex from a file
- Subject: Reading Hex from a file
- From: Jon <email@hidden>
- Date: Wed, 31 Dec 1969 23:57:21 -0700
Actually, I have since switched it to use open/read, but it does exactly the same thing. here is my code:
(I am almost positive that HEXstr isn't the problem since the NSLog is screwy too. I might be interpreting them as UTF-8 (I am a newbie to this, please be understanding), because I tell it to read 81 bytes and it only outputs four or five characters. It did the exact same with fopen/fread. So, what newbie mistake am I making this time ;)
/*** Declarations ***/
char *hheader;
int aaoFile;
hheader = (char*) malloc (81);
aaoFile = open([path cString],O_RDONLY,"777");
/*** ACTUAL CODE ***/
lseek(aaoFile,0,SEEK_SET); read(aaoFile,hheader,81);
NSLog(@"%s",hheader);
NSString *headStr = [self HEXstr:hheader];
//*** UI ***/
[headerField setString:headStr];
/*** Clean-Up ***/
close(aaoFile);
free(hheader);
Thanks,
jjoonathan
On Jan 8, 2005, at 2:01 AM, Andrew Farmer wrote:
On 07 Jan 2005, at 22:07, Jon wrote:
I need to read hex values from a file. I use fopen/fseek/fread/fclose to open and read my data (then convert the characters into hex).
That sounds like it should work.
For some reason, the characters (before being converted into hex) are different from what I see in my hex editor... The characters fread puts into my character array are what I see if I open the file in text edit and look at the file.
That doesn't sound right. Are you sure that the program that is reading the characters isn't interpretting them as UTF-8?
(Sample code would be nice, too. Show us what you're doing.)
_______________________________________________
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