feat(utf-8 string): implemented remove range function
This commit is contained in:
parent
15abfcffe8
commit
8b3be3d1cb
3 changed files with 18 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ FledastyError fledasty_utf8_string_insert_after_string(FledastyUtf8String *curre
|
|||
|
||||
FledastyError fledasty_utf8_string_pop(FledastyUtf8String *current_string);
|
||||
FledastyError fledasty_utf8_string_remove(FledastyUtf8String *current_string, unsigned char *character_string, size_t character_string_size);
|
||||
FledastyError fledasty_utf8_string_remove_range(FledastyUtf8String *current_string, size_t start_index, size_t end_index);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -222,6 +222,21 @@ FledastyError fledasty_utf8_string_remove(FledastyUtf8String *current_string, un
|
|||
return FLEDASTY_ERROR_NONE;
|
||||
}
|
||||
|
||||
FledastyError fledasty_utf8_string_remove_range(FledastyUtf8String *current_string, size_t start_index, size_t end_index) {
|
||||
if (current_string == NULL) {
|
||||
return FLEDASTY_ERROR_INVALID_POINTER;
|
||||
}
|
||||
|
||||
if (start_index > end_index || end_index > current_string->size) {
|
||||
return FLEDASTY_ERROR_INDEX_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
hallocy_move_memory(current_string->character_string + start_index, current_string->character_string + end_index, current_string->size - end_index);
|
||||
current_string->size -= end_index - start_index;
|
||||
|
||||
return FLEDASTY_ERROR_NONE;
|
||||
}
|
||||
|
||||
FledastyError fledasty_utf8_string_clear(FledastyUtf8String *current_string) {
|
||||
if (current_string == NULL) {
|
||||
return FLEDASTY_ERROR_INVALID_POINTER;
|
||||
|
|
|
|||
|
|
@ -243,6 +243,8 @@ int main() {
|
|||
printf("Pop: %s\n", test_utf8_string.character_string);
|
||||
fledasty_utf8_string_remove(&test_utf8_string, (unsigned char*)"𓃶 ", 5);
|
||||
printf("Remove: %s\n", test_utf8_string.character_string);
|
||||
fledasty_utf8_string_remove_range(&test_utf8_string, 0, 5);
|
||||
printf("Remove range: %s\n", test_utf8_string.character_string);
|
||||
|
||||
if (fledasty_utf8_string_has_string(&test_utf8_string, (unsigned char*)"😀", 4)) {
|
||||
printf("String contains 😀!\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue