2023-06-25 15:14:06 +02:00
|
|
|
#ifndef __LIBCPROJECT_CHARACTER__
|
|
|
|
#define __LIBCPROJECT_CHARACTER__
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-08-07 00:11:07 +02:00
|
|
|
#include <errno.h>
|
2023-01-05 19:28:05 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2023-01-07 19:38:01 +01:00
|
|
|
#include "string.h"
|
2023-06-25 15:07:34 +02:00
|
|
|
#include "types.h"
|
2023-01-07 19:38:01 +01:00
|
|
|
|
2023-01-05 19:28:05 +01:00
|
|
|
/**
|
|
|
|
* @brief Append a character to a string, assuming string points to an array
|
|
|
|
* with enough space.
|
|
|
|
*
|
2023-08-09 20:17:54 +02:00
|
|
|
* @param string
|
2023-01-05 19:28:05 +01:00
|
|
|
* @param character
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
2023-08-06 23:17:07 +02:00
|
|
|
void character_append(string_t string, char character);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Append a character to a string at a specific index, assuming string points to an array with enough space.
|
|
|
|
*
|
2023-08-06 23:17:07 +02:00
|
|
|
* @param string
|
2023-01-05 19:28:05 +01:00
|
|
|
* @param character
|
|
|
|
* @param index
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
2023-08-06 23:17:07 +02:00
|
|
|
void character_append_at(string_t string, const char character, const size_t index);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Converts the character to uppercase.
|
|
|
|
*
|
|
|
|
* @param character
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
|
|
|
char character_to_upper(const char character);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Converts the character to lowercase.
|
|
|
|
*
|
|
|
|
* @param character
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
|
|
|
char character_to_lower(const char character);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check if the character is a digit ('0', '1', '2', '3', '4', '5', '6', '7, '8' or '9').
|
|
|
|
*
|
2023-08-09 21:08:15 +02:00
|
|
|
* @param character
|
2024-09-25 14:57:34 +02:00
|
|
|
* @return bool
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
|
|
|
bool character_get_is_digit(const char character);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the position in latin alphabet of the letter (case-insensitive) from 1 to 26.
|
|
|
|
* Return 0 if the character is not a letter.
|
|
|
|
*
|
|
|
|
* @param character
|
2024-09-25 14:26:15 +02:00
|
|
|
* @return uint8_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
2023-01-05 19:28:05 +01:00
|
|
|
*/
|
2024-09-25 14:26:15 +02:00
|
|
|
uint8_t character_get_alphabet_position(const char character);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
#endif
|