forked from pyrite-dev/milsko
have MwStringIsKeyUTF8 not use ub
This commit is contained in:
parent
4d7b33741f
commit
32f99b62b6
1 changed files with 12 additions and 3 deletions
15
src/string.c
15
src/string.c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue