If you are planning to make a suggestion on a machine with a small collation, you need to pay attention to the topic of the collation.
This problem was encountered yesterday when I processed the IP address.
X86 refers to the small-End Word collation, while the Web Hosting refers to the large-End Word collation. The first four digits of the IP Address Sequence are the version sequence, and the last four digits are the sequence length. That is, version = 0x4 (IPv4 ), length = 0x5 (20 characters in length), and 0x45 occurs on the webpage. If we define a structure sta to capture:
Strruct sta
{
Unsigned char b4version: 4;
Unsigned char b4headlen: 4;
};
Func ()
{
...
Sta X;
Memcpy (& X, Buf, sizeof (x); // the pseudo-configuration Buf is an IP address text, and the first word is 0x45
...
}
So what is the difference between b4version and b4headlen?
Sorry, I'm sorry to tell you that the machine is in the small-end Character Sequence, b4version = 0x5, b4headlen = 0x4!
This structure allocates segments starting from low positions, that is, b4version uses 4 lower bits and b4headlen uses 4 Higher bits, however, 0x45 means that 0100 0101b is very clear, and 4 lower bits are 0101b = 5, and 4 Higher bits are 0100b = 4, so it is reversed.
Solution: Let me think about it...