feat(utf-8 string): added setting value of utf-8 string through unsigned char*

This commit is contained in:
Mineplay 2025-05-04 06:54:17 -05:00
parent c4db620fb4
commit 2353358199
3 changed files with 10 additions and 2 deletions

View file

@ -35,4 +35,6 @@ typedef struct {
} FledastyUtf8String;
FledastyError fledasty_utf8_string_initialize(FledastyUtf8String *new_string, unsigned char *character_string, size_t character_string_length);
FledastyError fledasty_utf8_string_destroy(FledastyUtf8String *current_string);
FledastyError fledasty_utf8_string_destroy(FledastyUtf8String *current_string);
FledastyError fledasty_utf8_string_append(FledastyUtf8String *current_string, unsigned char *character_string);

View file

@ -44,6 +44,9 @@ FledastyError fledasty_utf8_string_initialize(FledastyUtf8String *new_string, un
new_string->capacity = new_string->size + new_string->size;
new_string->character_string = hallocy_malloc(new_string->capacity);
for (size_t index = 0; index < new_string->size; index += 1) {
new_string->character_string[index] = character_string[index];
}
}
new_string->character_string[new_string->size] = '\0';

View file

@ -223,7 +223,10 @@ int main() {
fledasty_hash_table_destroy(&test_hash_table);
FledastyUtf8String test_utf8_string;
fledasty_utf8_string_initialize(&test_utf8_string, "€Testing", 11);
unsigned char *test_string = (unsigned char*)"😀€Testing";
fledasty_utf8_string_initialize(&test_utf8_string, test_string, 11);
printf("%s\n", test_string);
printf("%s\n", test_utf8_string.character_string);
fledasty_utf8_string_destroy(&test_utf8_string);
printf("Done\n");