str_extra.c

Extra string functions library for C
git clone git://git.finwo.net/lib/str_extra.c
Log | Files | Refs | README

README.md (1346B)


      1 # c-strextra
      2 
      3 A lightweight C library providing additional string utility functions.
      4 
      5 ## Functions
      6 
      7 ### `str_isHex(const char *subject)`
      8 Checks if a string contains only hexadecimal characters (0-9, a-f, A-F).
      9 Returns `true` if all characters are hex digits, `false` otherwise.
     10 
     11 ### `strnstr(const char *haystack, const char *needle, size_t len)`
     12 Finds the first occurrence of a substring in a string with a length limit.
     13 Similar to `strstr()` but only searches the first `len` characters.
     14 Returns a pointer to the found substring or `NULL` if not found.
     15 
     16 ### `strtoupper(char *str)`
     17 Converts all characters in a string to uppercase.
     18 Modifies the input string in-place and returns a pointer to it.
     19 
     20 ### `strcasecmp(const char *a, const char *b)`
     21 Case-insensitive string comparison.
     22 On Windows (where this function may not be available), provides a custom implementation.
     23 Returns 0 if strings are equal (case-insensitive), negative if `a < b`, positive if `a > b`.
     24 
     25 ## Usage
     26 
     27 Include the main header file:
     28 
     29 ```c
     30 #include "str_extra.h"
     31 ```
     32 
     33 Or include individual headers for specific functions.
     34 
     35 ## Platform Support
     36 
     37 - Works on POSIX systems (Linux, macOS) and Windows
     38 - `strcasecmp` uses system implementation where available, provides fallback for Windows
     39 - Standard C library dependencies: `<ctype.h>`, `<string.h>`, `<stdlib.h>`, `<stdbool.h>`