have MwStringIsKeyUTF8 not use ub

This commit is contained in:
IoI_xD 2026-04-14 19:51:52 -07:00
commit 32f99b62b6

View file

@ -51,9 +51,18 @@ void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) {
};
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key) {
unsigned char bytes[sizeof(MwU32) * 16];
int i;
memcpy(bytes, &key, sizeof(MwU32));
/* little endian */
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86) || defined(__aarch64__) || defined(_M_ARM64)
unsigned char bytes[4] = {
(key & 0x000000FF),
(key & 0x0000FF00) >> 8,
(key & 0x00FF0000) >> 16,
(key & 0xFF000000) >> 24,
};
#else
#error Unspecified architecture! This error exists here because above it is endian-specific code. Add your architecture above.
#endif
int i;
for(i = 0; i < sizeof(MwU32); i++) {
if(( // ASCII