reading from a binary file
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am getting an '18„N¦NÆN' instead of an '18' using fread. What is wrong here?
Thanks.
0 Commenti
Risposte (1)
Jan
il 25 Feb 2011
The command, you did not show, is wrong. This might be better:
A = fopen(FID, [1, 2], 'char=>char')
But this is a bold guess only. If you show the necessary details of your FREAD command and the corresponding data, a useful help is more likely and less random.
10 Commenti
Walter Roberson
il 28 Feb 2011
The data that the OP read in at first appears to me to potentially be UTF-8 encoded, based upon the characters that the OP shows. I am concerned that if the OP continues to work with this data stream that the OP might encounter cases where the difference between reading "char" and "uint8" might become important. It would be safer for the OP to use uint8=>char if reading bytes if the OP's intent.
Jan
il 28 Feb 2011
No. If the OP reads a Unicode file, he will most likely open it in the necessary encoding scheme. If he then switchs from the working "fread(fid, 2, '*char')" to "fread(fid, 2, 'uint8=>char')" he will get a different unwanted result.
Now you found a point, were we two disagree. But who cares?
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!