2022-05-31 15:27:46 +03:00
|
|
|
/* This software is licensed by the MIT License, see LICENSE file */
|
|
|
|
/* Copyright © 2022 Gregory Lirent */
|
|
|
|
|
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
int charsize(const char* s) {
|
|
|
|
|
|
|
|
unsigned int v;
|
|
|
|
if (*(unsigned char*)s <= 0x7f)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
memcpy(&v, s, 4);
|
|
|
|
|
|
|
|
if (IS_LITTLE_ENDIAN) {
|
2022-06-03 17:41:56 +03:00
|
|
|
if ((v&0x0000c0e0) == 0x000080c0) return 2;
|
|
|
|
if ((v&0xc0c0c0f8) == 0x808080f0) return 4;
|
|
|
|
if ((v&0x00c0c0f0) == 0x008080e0) return 3;
|
2022-05-31 15:27:46 +03:00
|
|
|
} else {
|
2022-06-03 17:41:56 +03:00
|
|
|
if ((v&0xe0c00000) == 0xc0800000) return 2;
|
|
|
|
if ((v&0xf8c0c0c0) == 0xf0808080) return 4;
|
|
|
|
if ((v&0xf0c0c000) == 0xe0808000) return 3;
|
2022-05-31 15:27:46 +03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|