Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
Getting Hex data out of a file into a string
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement