signed chars are a nightmare they should be deleted

This commit is contained in:
Blendi-Goose 2025-06-27 22:04:12 +02:00
parent 6c2a4fdc11
commit b60fd8e140

View File

@ -2,12 +2,13 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
bool nn_unicode_is_continuation(char byte) { bool nn_unicode_is_continuation(unsigned char byte) {
return (byte >> 6) == 0b10; return (byte >> 6) == 0b10;
} }
bool nn_unicode_validate(const char *s) { bool nn_unicode_validate(const char *b) {
// TODO: validate UTF-8-ness // TODO: validate UTF-8-ness
const unsigned char* s = (const unsigned char*)b;
while (*s) { while (*s) {
if(s[0] <= 0x7F) { if(s[0] <= 0x7F) {
s++; s++;
@ -81,8 +82,9 @@ unsigned int *nn_unicode_codepoints(const char *s) {
return buf; return buf;
} }
size_t nn_unicode_len(const char *s) { size_t nn_unicode_len(const char *b) {
size_t count = 0; size_t count = 0;
const unsigned char* s = (const unsigned char*)b;
while (*s) { while (*s) {
count++; count++;
if(s[0] <= 0x7F) { if(s[0] <= 0x7F) {