65 lines
3.6 KiB
C
65 lines
3.6 KiB
C
/*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* -----------------------------------------------------------------------------
|
|
* File: UTF8String.h
|
|
* Description:
|
|
* This file contains the UTF8String structure and the functions for modifying it.
|
|
* It includes functions to append, Insert at index, insert before character,
|
|
* insert before string, insert after character, insert after string, replace,
|
|
* copy, pop, remove, remove range, clear, check if contains string, check if
|
|
* empty.
|
|
*
|
|
* Author: Mineplay
|
|
* -----------------------------------------------------------------------------
|
|
*/
|
|
#ifndef FLEDASTY_UTF8_STRING
|
|
#define FLEDASTY_UTF8_STRING
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "../Utils/Error.h"
|
|
|
|
typedef struct {
|
|
size_t size, capacity;
|
|
unsigned char *character_string;
|
|
} FledastyUtf8String;
|
|
|
|
FledastyError fledasty_utf8_string_free(FledastyUtf8String *current_string);
|
|
|
|
FledastyError fledasty_utf8_string_append(FledastyUtf8String *current_string, unsigned char *character_string, const size_t character_string_size);
|
|
FledastyError fledasty_utf8_string_insert_at_index(FledastyUtf8String *current_string, size_t index, unsigned char *character_string, const size_t character_string_size);
|
|
FledastyError fledasty_utf8_string_insert_before_string(FledastyUtf8String *current_string, unsigned char *before_character_string, const size_t before_character_string_size, unsigned char *character_string, const size_t character_string_size);
|
|
FledastyError fledasty_utf8_string_insert_after_string(FledastyUtf8String *current_string, unsigned char *after_character_string, const size_t after_character_string_size, unsigned char *character_string, const size_t character_string_size);
|
|
|
|
FledastyError fledasty_utf8_string_pop(FledastyUtf8String *current_string);
|
|
FledastyError fledasty_utf8_string_remove(FledastyUtf8String *current_string, unsigned char *character_string, const size_t character_string_size);
|
|
FledastyError fledasty_utf8_string_remove_range(FledastyUtf8String *current_string, const size_t start_index, const size_t end_index);
|
|
|
|
FledastyError fledasty_utf8_string_replace_string(FledastyUtf8String *current_string, unsigned char *replace_character_string, const size_t replace_character_string_size, unsigned char *character_string, const size_t character_string_size);
|
|
|
|
FledastyError fledasty_utf8_string_clear(FledastyUtf8String *current_string);
|
|
FledastyError fledasty_utf8_string_shrink_to_fit(FledastyUtf8String *current_string);
|
|
|
|
bool fledasty_utf8_string_has_string(const FledastyUtf8String *current_string, unsigned char *character_string, const size_t character_string_size);
|
|
static inline bool fledasty_utf8_string_is_empty(const FledastyUtf8String *current_string) { return current_string == NULL || current_string->size == 0; }
|
|
|
|
FledastyUtf8String fledasty_utf8_string_encode(const uint32_t *unicode, const size_t size);
|
|
uint32_t *fledasty_utf8_string_decode(const FledastyUtf8String *current_string, size_t *unicode_string_size);
|
|
|
|
bool fledasty_utf8_string_validate(unsigned char *character_string, const size_t character_string_size);
|
|
size_t fledasty_utf8_string_get_size(const unsigned char *character_string);
|
|
|
|
#endif
|