I’m having a problem using FileOutputStream write(const void*, size_t) function when the first data byte is either 0xE0, or 0xF0. The interesting part is that it depends on the number of bytes to be written. For example, if the second argument (number of bytes to write) is 0x800A, the file is written correctly even if the first byte is 0xF0. However, if the second argument is 0x159A (smaller file size), the file is written with what looks like random data and the file size is 0x1757 instead of 0x159A. In addition, if the first byte is 0xF0 and the file size is one byte less, 0x1599, the file is written correctly with the first byte of 0xF0 and a file size of 0x1599.
Can anybody make sense of this?