- uint16_t byte_order_mark;
- memcpy(&byte_order_mark, buf + offset, sizeof(uint16_t));
- if (byte_order_mark == 0xFFFE) {
+ uint8_t le_bom[] = {0xff, 0xfe};
+ uint8_t be_bom[] = {0xfe, 0xff};
+ if (memcmp(le_bom, buf + offset, sizeof(uint16_t)) == 0)