reading from a binary file
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am getting an '18„N¦NÆN' instead of an '18' using fread. What is wrong here?
Thanks.
0 Kommentare
Antworten (1)
Jan
am 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 Kommentare
Walter Roberson
am 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
am 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?
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!