@fryn3,
I have read the demand again, and it's like this:
The 0x89 byte should come first, the 0x01 byte second.
So the only portable way to do is your proposal, slightly adopted by me:
const std::uint16_t FOO = 0x8901;
QByteArray ba;
ba.append(char(FOO >> 8)); // 0x89
ba.append(char(FOO & 0xFF)); // 0x01
Static casting the 16-Bit word is not endian-awere, the same applies for this one:
cout << hex << int((uint8_t)&t) << " " << int((((uint8_t)&t) + 1));
which is by the way, wrong as 0x01 comes first here.
And if you try this on a big endian machine, it will give other results.
Regards