How to find out endianness of a file?
问题 How can I figure out whether it's a big-endian or little-endian file? I just tried to write a big-endian file with matlab but probably it didn't work. Now I want to learn if it is possible to learn what type it is. Any suggestion? 回答1: Use FOPEN: fileID = fopen(fileName) [filename, permission, machineformat] = fopen(fileID) The third output, machineformat , tells you whether it's big endian ( 'b' ) or little endian ( 'l' ). 回答2: There's no way in general to know whether a given data file was