GuiarStr is a comprehensive, professional-grade string manipulation library for C programmers.
While C has very basic string support, GuiarStr provides a rich set of modern string operations with:
- Dynamic strings
- Unicode/UTF-8 support
- Memory safety
- Efficient performance
Perfect for embedded systems to complex multilingual software β without external dependencies.
| Function | Description |
| guiarstr_trim | Removes leading and trailing whitespace. |
| guiarstr_strip | Removes specified characters from both ends. |
| guiarstr_tolower / guiarstr_toupper | Converts string to lowercase/uppercase (in-place). |
| guiarstr_reverse | Reverses a string (UTF-8 safe). |
| guiarstr_replace | Replaces all occurrences of a substring.
| guiarstr_replace_n | Replaces with a limit on replacements.
| guiarstr_replace_char | Replaces all occurrences of a
character.
| guiarstr_remove_chars | Removes all specified characters.|
guiarstr_starts_with/guiarstr_ends_withβ Prefix/suffix checking.guiarstr_starts_withi/guiarstr_endswithiβ Case-insensitive variants.guiarstr_containsβ Checks if a string contains a substring.guiarstr_countβ Counts occurrences of a substring.guiarstr_find/guiarstr_rfindβ Find substring positions.guiarstr_find_char/guiarstr_rfind_charβ Find character positions.guiarstr_find_any/guiarstr_find_not_anyβ Advanced character search.
guiarstr_splitβ Splits by character delimiter.guiarstr_split_strβ Splits by string delimiter.guiarstr_split_anyβ Splits by any of multiple delimiters.guiarstr_split_linesβ Splits by line endings (handles\n,\r\n).guiarstr_joinβ Joins string array with separator.guiarstr_join_viewsβ Joins string views efficiently.
guiarstr_createβ Creates a dynamic string.guiarstr_appendβ Appends to a dynamic string.guiarstr_insertβ Inserts at a specific position.guiarstr_removeβ Removes a range of characters.guiarstr_reserveβ Pre-allocates memory.guiarstr_resizeβ Resizes with fill character.guiarstr_shrink_to_fitβ Optimizes memory usage.
guiarstr_builder_createβ Creates an efficient string builder.guiarstr_builder_appendβ Appends strings efficiently.guiarstr_builder_append_fmtβ Appends formatted strings.guiarstr_builder_buildβ Builds the final string.
guiarstr_utf8_lenβ Gets UTF-8 character count.guiarstr_utf8_char_lenβ Gets byte length of a UTF-8 character.guiarstr_utf8_byte_posβ Converts character position to byte position.guiarstr_utf8_validateβ Validates UTF-8 sequences.guiarstr_utf8_widthβ Gets display width for monospace fonts.guiarstr_utf8_substringβ Extracts UTF-8 substring.
β Handles emojis, Arabic, and all Unicode characters correctly.
guiarstr_to_int/guiarstr_from_intguiarstr_to_double/guiarstr_from_doubleguiarstr_to_long/guiarstr_from_long
β Includes error handling.
guiarstr_printfβ Creates formatted strings.guiarstr_append_printfβ Appends formatted strings to dynamic strings.
guiarstr_read_fileβ Reads entire file into a string.guiarstr_write_fileβ Writes string content to file.
- Comprehensive error codes with descriptive messages.
- All functions return error status for safe operation.
guiarstr_error_messageβ Gets human-readable error descriptions.
- Fully UTF-8 aware operations.
- Works perfectly for multilingual apps and terminal-based UIs.
- Supports byte-level and character-level manipulation.
make # Builds static lib (libguiarstr.a) + shared lib (libguiarstr.so)
make test # Runs the test suite
make example # Builds usage demomake install PREFIX=$HOME/.local-
guiarstr.h β $PREFIX/include
-
libguiarstr.a and libguiarstr.so β $PREFIX/lib
-
guiarstr.pc β $PREFIX/lib/pkgconfig
mkdir build && cd build
cmake ..
make
sudo make installBasic Operations :
#include <stdio.h>
#include "guiarstr.h"
int main() {
char text[] = " Hello World ";
printf("Trimmed: '%s'\n", guiarstr_trim(text));
size_t count;
char** parts = guiarstr_split_str("oneXYZtwoXYZthree", "XYZ", &count);
for (size_t i = 0; i < count; ++i) {
printf("Part %zu: %s\n", i + 1, parts[i]);
}
guiarstr_split_free(parts, count);
char* reversed = guiarstr_reverse("okbaπdev");
printf("Reversed: %s\n", reversed);
free(reversed);
}#include "guiarstr.h"
int main() {
GuiarStr* str = guiarstr_create("Hello");
guiarstr_append(str, " World");
guiarstr_append_char(str, '!');
guiarstr_insert(str, 5, " there");
printf("Dynamic string: '%s'\n", str->data);
guiarstr_free(str);
}#include "guiarstr.h"
int main() {
GuiarStrBuilder* builder = guiarstr_builder_create(16);
guiarstr_builder_append(builder, "The answer is: ");
guiarstr_builder_append_fmt(builder, "%d", 42);
GuiarStr* result = guiarstr_builder_build(builder);
printf("Built: '%s'\n", result->data);
guiarstr_free(result);
guiarstr_builder_free(builder);
}#include "guiarstr.h"
int main() {
const char* text = "Ω
Ψ±ΨΨ¨Ψ§ π";
printf("UTF-8 length: %zu characters\n", guiarstr_utf8_len(text));
printf("Byte length: %zu bytes\n", strlen(text));
printf("Display width: %zu columns\n", guiarstr_utf8_width(text));
char* substr = guiarstr_utf8_substring(text, 2, 2);
printf("Substring [2:4]: '%s'\n", substr);
free(substr);
}
gcc main.c $(pkg-config --cflags --libs guiarstr) -o appexport PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfigguiarstr/
βββ include/ # Public headers
β βββ guiarstr.h
βββ src/ # Implementation
β βββ guiarstr.c
βββ tests/ # Tests
β βββ main.c
βββ examples/ # Example programs
β βββ usage.c
βββ assets/ # Images
β βββ build_and_test.png
βββ CMakeLists.txt
βββ guiarstr.pc
βββ guiarstr.pc.in
βββ Makefile
βββ README.md
βββ CHANGELOG.md
βββ LICENSEContributions are welcome! Please feel free to submit a Pull Request.
Fork the repository Create your feature branch
(git checkout -b feature/amazing-feature)Commit your changes
(git commit -m 'Add some amazing feature')Push to the branch
(git push origin feature/amazing-feature)Open a Pull Request.
π€ Name: GUIAR OQBA
π§ Email: [email protected]
π ORCID: 0009-0008-1629-0002
πΌ LinkedIn: guiar-oqba
π» GitHub: okba14
π Zenodo: 15786076
π Hashnode: @okba
π± Phone: +2136-71-36-04-38
Β© 2025 GUIAR OQBA π©πΏ
Made with π» & β€οΈ from Algeria
Thank you for your support! π