Any way to read big endian data with little endian program?

前端 未结 8 1849
走了就别回头了
走了就别回头了 2021-01-13 13:50

An external group provides me with a file written on a Big Endian machine, and they also provide a C++ parser for the file format.

I only can run the parser on a lit

8条回答
  •  我在风中等你
    2021-01-13 14:12

    Your question somehow conatins the answer: No!

    I only can run the parser on a little endian machine - is there any way to read the file using their parser without add a swapbytes() call after each read?

    If you read (and want to interpret) big endian data on a little endian machine, you must somehow and somewhere convert the data. You might do this after each read or after the whole file has been read (if the data read does not contain any information on how to read further data) - but there is no way in omitting the conversion.

提交回复
热议问题