nga-c: implement more utf32_ functions
FossilOrigin-Name: 528dbf1960c805bee6c2048fda5b354e0c5bd02dc44bca787df9c7845c12039e
This commit is contained in:
parent
d008cfc764
commit
f734da8780
2 changed files with 2663 additions and 2627 deletions
5246
vm/nga-c/image.c
5246
vm/nga-c/image.c
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,41 @@
|
||||||
int utf32_length(int *s, int max) {
|
size_t utf32_strlen(const int32_t *utf32_str) {
|
||||||
int l = 0;
|
size_t length = 0;
|
||||||
while (*s++ != 0 && l < max) l++;
|
while (utf32_str[length] != 0) {
|
||||||
return l;
|
length++;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
void utf32_strcpy(int32_t *dest, const int32_t *src) {
|
||||||
|
while ((*dest++ = *src++) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int utf32_strcmp(const int32_t *str1, const int32_t *str2) {
|
||||||
|
while (*str1 && (*str1 == *str2)) {
|
||||||
|
str1++;
|
||||||
|
str2++;
|
||||||
|
}
|
||||||
|
return *str1 - *str2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void c_to_utf32(const char *source, int32_t *dest, int max) {
|
||||||
|
int i = 0;
|
||||||
|
while (source[i] != '\0' && i < max - 1) {
|
||||||
|
dest[i] = (int32_t)source[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
dest[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void utf32_to_c(const int32_t *source, char *dest, int max) {
|
||||||
|
int i = 0;
|
||||||
|
while (source[i] != 0 && i < max - 1) {
|
||||||
|
if (source[i] <= 0x7F) {
|
||||||
|
dest[i] = (char)source[i];
|
||||||
|
} else {
|
||||||
|
dest[i] = '?';
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
dest[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue