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

前端 未结 8 1763
走了就别回头了
走了就别回头了 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:18

    In general, no.

    If the read/write calls are not type aware (which, for example fread and fwrite are not) then they can't tell the difference between writing endian sensitive data and endian insensitive data.

    Depending on how the parser is structured you may be able to avoid some suffering, if the I/O functions they use are aware of the types being read/written then you could modify those routines apply the correct endian conversions.

    If you do have to modify all the read/write calls then creating just such a routine would be a sensible course of action.

提交回复
热议问题