61 lines
2.5 KiB
C
61 lines
2.5 KiB
C
#ifndef STROPS_H
|
|
#define STROPS_H
|
|
|
|
#include <stddef.h>
|
|
|
|
/*
|
|
ATTENTION! THIS LIBRARY CURRENTLY LEAKS MEMORY!
|
|
Functions that return char*, return a new heap-allocated string.
|
|
The user of this library is responsible for freeing the memory of the result.
|
|
No function modifies the input string. The input string is copied at the beginning of a function.
|
|
Only 7-Bit Ascii is supported.
|
|
*/
|
|
|
|
typedef unsigned long long ull_t;
|
|
|
|
char contains_char(const char* string, char char_to_search);
|
|
char contains_string(const char* string, const char* string_to_search);
|
|
|
|
char* strops_to_lowercase(const char* string);
|
|
char* strops_to_uppercase(const char* string);
|
|
int strops_is_lowercase(const char* string);
|
|
int strops_is_uppercase(const char* string);
|
|
|
|
char* strops_insert_at_pos_string(const char* string, const char* string_to_insert, ull_t pos);
|
|
char* strops_remove_at_pos_char(const char* string, ull_t pos);
|
|
char* strops_remove_at_pos_string(const char* string, const char* string_to_remove, ull_t pos);
|
|
char* strops_replace_at_pos_string(const char* string, const char* string_to_remove, const char* string_to_insert, ull_t pos);
|
|
|
|
char* strops_trim_right_whitespace(const char* string);
|
|
char* strops_trim_left_whitespace(const char* string);
|
|
char* strops_trim_both_whitespace(const char* string);
|
|
|
|
char* strops_trim_right_chars(const char* string, const char* chars_to_remove);
|
|
char* strops_trim_left_chars(const char* string, const char* chars_to_remove);
|
|
char* strops_trim_both_chars(const char* string, const char* chars_to_remove);
|
|
|
|
char* strops_trim_right_string(const char* string, const char* string_to_remove);
|
|
char* strops_trim_left_string(const char* string, const char* string_to_remove);
|
|
char* strops_trim_both_string(const char* string, const char* string_to_remove);
|
|
|
|
char* strops_remove_chars(const char* string, const char* chars_to_remove);
|
|
char* strops_remove_string(const char* string, const char* string_to_remove);
|
|
|
|
ull_t strops_word_count(const char* string);
|
|
|
|
int strops_is_url_encoded(const char* string);
|
|
|
|
/*
|
|
https://www.w3schools.com/tags/ref_urlencode.asp
|
|
PLEASE NEVER USE THEM WITHOUT UNDERSTANDING THEIR ISSUES!
|
|
They will fully remove the following '%20 %21 %22 %23 %24 %26 %27 %28 %29 %2A %2C %2E %2F \
|
|
%3B %3C %3E %3F %5B %5C %5D %5E %60 %7B %7C %7D %7E'
|
|
These will get turned into their ascii counterpart '%25 %2B %2D %2E %2F %3A %3D %40 %5F'
|
|
They will return NULL on failure
|
|
*/
|
|
char* strops_url_encode(const char* string);
|
|
char* strops_url_decode(const char* string);
|
|
|
|
#endif /* STROPS_H */
|
|
|