C Collections

cstring · Section 3

cstring_trim

cstring_trim - strip leading and trailing whitespace in-place

C Collections (libccollections, -lccollections)

#include <ccollections/cstring.h>
 
void cstring_trim(cstr s);

This function removes all leading and trailing white space from the
string, in place. White space means the six ASCII bytes space, '\t',
'\n', '\v', '\f' and '\r', in every locale, because the function
doesn't ask the locale the way isspace() does. No other byte counts as
white space, so a byte above 0x7F, such as a no-break space or a piece of
a UTF-8 sequence, is never removed and a UTF-8 string stays valid. White
space inside the string is kept.

s   String to change

A string that holds nothing but white space becomes empty
Asserts if s is NULL

cstring_to_upper(3), cstring_to_lower(3)