feat(utf-8 string): implemented clear function

This commit is contained in:
Mineplay 2025-05-15 10:20:54 -05:00
parent 6ccf2e70bf
commit 681ca8f489
3 changed files with 14 additions and 1 deletions

View file

@ -43,6 +43,7 @@ FledastyError fledasty_utf8_string_insert_before_string(FledastyUtf8String *curr
FledastyError fledasty_utf8_string_insert_after_string(FledastyUtf8String *current_string, unsigned char *after_character_string, size_t after_character_string_size, unsigned char *character_string, size_t character_string_size);
FledastyError fledasty_utf8_string_pop(FledastyUtf8String *current_string);
FledastyError fledasty_utf8_string_clear(FledastyUtf8String *current_string);
FledastyError fledasty_utf8_string_replace_string(FledastyUtf8String *current_string, unsigned char *replace_character_string, size_t replace_character_string_size, unsigned char *character_string, size_t character_string_size);

View file

@ -198,6 +198,17 @@ FledastyError fledasty_utf8_string_pop(FledastyUtf8String *current_string) {
return FLEDASTY_ERROR_NONE;
}
FledastyError fledasty_utf8_string_clear(FledastyUtf8String *current_string) {
if (current_string == NULL) {
return FLEDASTY_ERROR_INVALID_POINTER;
}
current_string->size = 0;
current_string->character_string[0] = '\0';
return FLEDASTY_ERROR_NONE;
}
FledastyError fledasty_utf8_string_replace_string(FledastyUtf8String *current_string, unsigned char *replace_character_string, size_t replace_character_string_size, unsigned char *character_string, size_t character_string_size) {
if (current_string == NULL || replace_character_string == NULL || replace_character_string_size == 0 || character_string == NULL || character_string_size == 0) {
return FLEDASTY_ERROR_INVALID_POINTER;

View file

@ -266,7 +266,8 @@ int main() {
if (!fledasty_utf8_string_validate(invalid_utf8, 2)) {
printf("UTF-8 invalid string is invalid!\n");
}
fledasty_utf8_string_clear(&test_utf8_string);
if (fledasty_utf8_string_is_empty(&test_utf8_string)) {
printf("UTF-8 string is empty!\n");
}