Author Topic: CkByteData/append2 Default BigEndian?  (Read 390 times)


  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
CkByteData/append2 Default BigEndian?
« on: January 14, 2018, 10:54:15 AM »
So I'm working with some data I'll be sending over the network and originally was appending an entire structure using the following.

struct PacketHeader{
        short size;
        short header;
        short type;

struct ResponseStruct{
        PacketHeader header;
        int Data1;
        int Data2;

CkByteData ResponseData;

When I do this it seems all of the data ends up swapped to big-endian vs little-endian, is there any way to account for that without having to append data individually tot he CkByteData object and set little-endian to true? I.E. Is there a way to set CkByteData to little-endian by default? I'm not sure if this is an issue with my struct being big-endian to begin with (I would assume not considering my system is little-endian and I'm manually assigning some of the values which are incorrect).

I had thought using the byteSwap4321 would work (I'm tired) but of course instead of shifting individual data (How is chilkat supposed to know what individual data? yeah I know) it seemed to have shifted the entire thing.

What doesn't make sense to me personally is if byteSwap4321 doesn't work as expected how is the data big-endian in the first place so I'm a bit confused and looking for advice on a way to handle this problem which doesn't require me to individually append each piece of data while setting little-endian to true, if possible.