Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting Hex data out of a file into a string
Message
From
18/10/2000 17:42:59
Josh Fedke
National Financial Corporation
Milwaukee, Wisconsin, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Getting Hex data out of a file into a string
Miscellaneous
Thread ID:
00431199
Message ID:
00431199
Views:
42
I'm trying to get the size of a image file using the bytes in the header. What I can't seem to negotiate is that fgets() translates the bytes it pulls from the file into their ASCII equivalent.
I just want the the hex values because I need to swap an upper and lower byte (endianess?) before doing evaluate("0x" + hex_size). In C/C++ you can change the stream extraction type or cast the extracted values. Can Foxpro do something like this, so that hex values can be extracted from a file?
Also, " alltrim(str(asc(fgets(file_handle,1)))) " doesn't work because when hex A-F appear, fgets doesn't convert them to a valid ASCII character and then " alltrim(str(asc( " won't work correctly. Thanks in advance.

-Josh
Next
Reply
Map
View

Click here to load this message in the networking platform