sstring.h: string handling


Provided functions allow efficient operations on strings. Internal string format is binary, supporting arbitrary data. Operations on strings involving format interpretation, e.g. string length is interpreted as UTF-8 when calling to the Unicode function ss_len_u(), and as raw data when calling the functions not using Unicode interpretation (ss_len()/ss_size()). Strings below 256 bytes take just 5 bytes for internal structure, and 5 * sizeof(size_t) for bigger strings. Unicode size is cached between operations, when possible, so in those cases UTF-8 string length computation would be O(1).

 ss_adler32  ss_cat_read  ss_cpy_enc_hex  ss_dup_cn  ss_dup_wn  ss_get_buffer_size 
 ss_adler32r  ss_cat_replace  ss_cpy_enc_lz  ss_dup_dec_b64  ss_empty  ss_getchar 
 ss_alloc  ss_cat_resize  ss_cpy_enc_lzh  ss_dup_dec_esc_dquote  ss_enc_HEX  ss_grow 
 ss_alloc_errors  ss_cat_resize_u  ss_cpy_erase  ss_dup_dec_esc_json  ss_enc_b64  ss_len 
 ss_alloca  ss_cat_rtrim  ss_cpy_erase_u  ss_dup_dec_esc_squote  ss_enc_esc_dquote  ss_len_u 
 ss_at  ss_cat_substr  ss_cpy_int  ss_dup_dec_esc_url  ss_enc_esc_json  ss_ltrim 
 ss_capacity  ss_cat_substr_u  ss_cpy_ltrim  ss_dup_dec_esc_xml  ss_enc_esc_squote  ss_max 
 ss_capacity_left  ss_cat_tolower  ss_cpy_printf  ss_dup_dec_hex  ss_enc_esc_url  ss_mh3_32 
 ss_cat  ss_cat_toupper  ss_cpy_printf_va  ss_dup_dec_lz  ss_enc_esc_xml  ss_mh3_32r 
 ss_cat_c  ss_cat_trim  ss_cpy_read  ss_dup_enc_HEX  ss_enc_hex  ss_ncmp 
 ss_cat_char  ss_cat_w  ss_cpy_replace  ss_dup_enc_b64  ss_enc_lz  ss_ncmpi 
 ss_cat_cn  ss_cat_wn  ss_cpy_resize  ss_dup_enc_esc_dquote  ss_enc_lzh  ss_popchar 
 ss_cat_dec_b64  ss_check  ss_cpy_resize_u  ss_dup_enc_esc_json  ss_encoding_errors  ss_printf 
 ss_cat_dec_esc_dquote  ss_clear  ss_cpy_rtrim  ss_dup_enc_esc_squote  ss_erase  ss_putchar 
 ss_cat_dec_esc_json  ss_clear_errors  ss_cpy_substr  ss_dup_enc_esc_url  ss_erase_u  ss_read 
 ss_cat_dec_esc_squote  ss_cmp  ss_cpy_substr_u  ss_dup_enc_esc_xml  ss_find  ss_ref 
 ss_cat_dec_esc_url  ss_cmpi  ss_cpy_tolower  ss_dup_enc_hex  ss_find_cn  ss_ref_buf 
 ss_cat_dec_esc_xml  ss_cpy  ss_cpy_toupper  ss_dup_enc_lz  ss_findb  ss_refa_buf 
 ss_cat_dec_hex  ss_cpy_c  ss_cpy_trim  ss_dup_enc_lzh  ss_findc  ss_replace 
 ss_cat_dec_lz  ss_cpy_char  ss_cpy_w  ss_dup_erase  ss_findcx  ss_reserve 
 ss_cat_enc_HEX  ss_cpy_cn  ss_cpy_wn  ss_dup_erase_u  ss_findnb  ss_resize 
 ss_cat_enc_b64  ss_cpy_dec_b64  ss_crc32  ss_dup_int  ss_findr  ss_resize_u 
 ss_cat_enc_esc_dquote  ss_cpy_dec_esc_dquote  ss_crc32r  ss_dup_ltrim  ss_findr_cn  ss_rtrim 
 ss_cat_enc_esc_json  ss_cpy_dec_esc_json  ss_cref  ss_dup_printf  ss_findrb  ss_set_turkish_mode 
 ss_cat_enc_esc_squote  ss_cpy_dec_esc_squote  ss_crefa  ss_dup_printf_va  ss_findrc  ss_shrink 
 ss_cat_enc_esc_url  ss_cpy_dec_esc_url  ss_dec_b64  ss_dup_read  ss_findrcx  ss_size 
 ss_cat_enc_esc_xml  ss_cpy_dec_esc_xml  ss_dec_esc_dquote  ss_dup_replace  ss_findrnb  ss_split 
 ss_cat_enc_hex  ss_cpy_dec_hex  ss_dec_esc_json  ss_dup_resize  ss_findru  ss_to_c 
 ss_cat_enc_lz  ss_cpy_dec_lz  ss_dec_esc_squote  ss_dup_resize_u  ss_findu  ss_to_w 
 ss_cat_enc_lzh  ss_cpy_enc_HEX  ss_dec_esc_url  ss_dup_rtrim  ss_fnv1  ss_tolower 
 ss_cat_erase  ss_cpy_enc_b64  ss_dec_esc_xml  ss_dup_substr  ss_fnv1a  ss_toupper 
 ss_cat_erase_u  ss_cpy_enc_esc_dquote  ss_dec_hex  ss_dup_substr_u  ss_fnv1ar  ss_trim 
 ss_cat_int  ss_cpy_enc_esc_json  ss_dec_lz  ss_dup_tolower  ss_fnv1r  ss_write 
 ss_cat_ltrim  ss_cpy_enc_esc_squote  ss_dup  ss_dup_toupper  ss_free 
 ss_cat_printf  ss_cpy_enc_esc_url  ss_dup_c  ss_dup_trim  ss_get_buffer 
 ss_cat_printf_va  ss_cpy_enc_esc_xml  ss_dup_char  ss_dup_w  ss_get_buffer_r 


uint32_t ss_adler32(const srt_string *s)



uint32_t ss_adler32r(const srt_string *s, uint32_t adler, size_t off1, size_t off2)



srt_string *ss_alloc(size_t initial_heap_reserve)



srt_bool ss_alloc_errors(const srt_string *s)



srt_string *ss_alloca(size_t max_size)



int ss_at(const srt_string *s, size_t off)



size_t ss_capacity(const srt_string *s)



size_t ss_capacity_left(const srt_string *s)



srt_string *ss_cat(srt_string **s, const srt_string *s1, ...)



srt_string *ss_cat_c(srt_string **s, const char *s1, ...)



srt_string *ss_cat_char(srt_string **s, int c)



srt_string *ss_cat_cn(srt_string **s, const char *src, size_t src_size)



srt_string *ss_cat_dec_b64(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_esc_dquote(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_esc_json(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_esc_squote(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_esc_url(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_esc_xml(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_hex(srt_string **s, const srt_string *src)



srt_string *ss_cat_dec_lz(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_HEX(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_b64(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_esc_dquote(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_esc_json(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_esc_squote(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_esc_url(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_esc_xml(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_hex(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_lz(srt_string **s, const srt_string *src)



srt_string *ss_cat_enc_lzh(srt_string **s, const srt_string *src)



srt_string *ss_cat_erase(srt_string **s, const srt_string *src, size_t off, size_t n)



srt_string *ss_cat_erase_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)



srt_string *ss_cat_int(srt_string **s, int64_t num)



srt_string *ss_cat_ltrim(srt_string **s, const srt_string *src)



srt_string *ss_cat_printf(srt_string **s, size_t size, const char *fmt, ...)



srt_string *ss_cat_printf_va(srt_string **s, size_t size, const char *fmt, va_list ap)



srt_string *ss_cat_read(srt_string **s, FILE *handle, size_t max_bytes)



srt_string *ss_cat_replace(srt_string **s, const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2)



srt_string *ss_cat_resize(srt_string **s, const srt_string *src, size_t n, char fill_byte)



srt_string *ss_cat_resize_u(srt_string **s, srt_string *src, size_t n, int fill_char)



srt_string *ss_cat_rtrim(srt_string **s, const srt_string *src)



srt_string *ss_cat_substr(srt_string **s, const srt_string *src, size_t off, size_t n)



srt_string *ss_cat_substr_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)



srt_string *ss_cat_tolower(srt_string **s, const srt_string *src)



srt_string *ss_cat_toupper(srt_string **s, const srt_string *src)



srt_string *ss_cat_trim(srt_string **s, const srt_string *src)



srt_string *ss_cat_w(srt_string **s, const char *s1, ...)



srt_string *ss_cat_wn(srt_string **s, const wchar_t *src, size_t src_size)



srt_string *ss_check(srt_string **s)



void ss_clear(srt_string *s)



void ss_clear_errors(srt_string *s)



int ss_cmp(const srt_string *s1, const srt_string *s2)



int ss_cmpi(const srt_string *s1, const srt_string *s2)



srt_string *ss_cpy(srt_string **s, const srt_string *src)



srt_string *ss_cpy_c(srt_string **s, ...)



srt_string *ss_cpy_char(srt_string **s, int c)



srt_string *ss_cpy_cn(srt_string **s, const char *src, size_t src_size)



srt_string *ss_cpy_dec_b64(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_esc_dquote(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_esc_json(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_esc_squote(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_esc_url(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_esc_xml(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_hex(srt_string **s, const srt_string *src)



srt_string *ss_cpy_dec_lz(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_HEX(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_b64(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_esc_dquote(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_esc_json(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_esc_squote(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_esc_url(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_esc_xml(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_hex(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_lz(srt_string **s, const srt_string *src)



srt_string *ss_cpy_enc_lzh(srt_string **s, const srt_string *src)



srt_string *ss_cpy_erase(srt_string **s, const srt_string *src, size_t off, size_t n)



srt_string *ss_cpy_erase_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)



srt_string *ss_cpy_int(srt_string **s, int64_t num)



srt_string *ss_cpy_ltrim(srt_string **s, const srt_string *src)



srt_string *ss_cpy_printf(srt_string **s, size_t size, const char *fmt, ...)



srt_string *ss_cpy_printf_va(srt_string **s, size_t size, const char *fmt, va_list ap)



srt_string *ss_cpy_read(srt_string **s, FILE *handle, size_t max_bytes)



srt_string *ss_cpy_replace(srt_string **s, const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2)



srt_string *ss_cpy_resize(srt_string **s, const srt_string *src, size_t n, char fill_byte)



srt_string *ss_cpy_resize_u(srt_string **s, srt_string *src, size_t n, int fill_char)



srt_string *ss_cpy_rtrim(srt_string **s, const srt_string *src)



srt_string *ss_cpy_substr(srt_string **s, const srt_string *src, size_t off, size_t n)



srt_string *ss_cpy_substr_u(srt_string **s, const srt_string *src, size_t char_off, size_t n)



srt_string *ss_cpy_tolower(srt_string **s, const srt_string *src)



srt_string *ss_cpy_toupper(srt_string **s, const srt_string *src)



srt_string *ss_cpy_trim(srt_string **s, const srt_string *src)



srt_string *ss_cpy_w(srt_string **s, ...)



srt_string *ss_cpy_wn(srt_string **s, const wchar_t *src, size_t src_size)



uint32_t ss_crc32(const srt_string *s)



uint32_t ss_crc32r(const srt_string *s, uint32_t crc, size_t off1, size_t off2)



const srt_string *ss_cref(srt_string_ref *s_ref, const char *c_str)



const srt_string *ss_crefa(const char *c_str)



srt_string *ss_dec_b64(srt_string **s, const srt_string *src)



srt_string *ss_dec_esc_dquote(srt_string **s, const srt_string *src)



srt_string *ss_dec_esc_json(srt_string **s, const srt_string *src)



srt_string *ss_dec_esc_squote(srt_string **s, const srt_string *src)



srt_string *ss_dec_esc_url(srt_string **s, const srt_string *src)



srt_string *ss_dec_esc_xml(srt_string **s, const srt_string *src)



srt_string *ss_dec_hex(srt_string **s, const srt_string *src)



srt_string *ss_dec_lz(srt_string **s, const srt_string *src)



srt_string *ss_dup(const srt_string *src)



srt_string *ss_dup_c(const char *src)



srt_string *ss_dup_char(int c)



srt_string *ss_dup_cn(const char *src, size_t src_size)



srt_string *ss_dup_dec_b64(const srt_string *src)



srt_string *ss_dup_dec_esc_dquote(const srt_string *src)



srt_string *ss_dup_dec_esc_json(const srt_string *src)



srt_string *ss_dup_dec_esc_squote(const srt_string *src)



srt_string *ss_dup_dec_esc_url(const srt_string *src)



srt_string *ss_dup_dec_esc_xml(const srt_string *src)



srt_string *ss_dup_dec_hex(const srt_string *src)



srt_string *ss_dup_dec_lz(const srt_string *src)



srt_string *ss_dup_enc_HEX(const srt_string *src)



srt_string *ss_dup_enc_b64(const srt_string *src)



srt_string *ss_dup_enc_esc_dquote(const srt_string *src)



srt_string *ss_dup_enc_esc_json(const srt_string *src)



srt_string *ss_dup_enc_esc_squote(const srt_string *src)



srt_string *ss_dup_enc_esc_url(const srt_string *src)



srt_string *ss_dup_enc_esc_xml(const srt_string *src)



srt_string *ss_dup_enc_hex(const srt_string *src)



srt_string *ss_dup_enc_lz(const srt_string *src)



srt_string *ss_dup_enc_lzh(const srt_string *src)



srt_string *ss_dup_erase(const srt_string *src, size_t off, size_t n)



srt_string *ss_dup_erase_u(const srt_string *src, size_t char_off, size_t n)



srt_string *ss_dup_int(int64_t num)



srt_string *ss_dup_ltrim(const srt_string *src)



srt_string *ss_dup_printf(size_t size, const char *fmt, ...)



srt_string *ss_dup_printf_va(size_t size, const char *fmt, va_list ap)



srt_string *ss_dup_read(FILE *handle, size_t max_bytes)



srt_string *ss_dup_replace(const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2)



srt_string *ss_dup_resize(const srt_string *src, size_t n, char fill_byte)



srt_string *ss_dup_resize_u(srt_string *src, size_t n, int fill_char)



srt_string *ss_dup_rtrim(const srt_string *src)



srt_string *ss_dup_substr(const srt_string *src, size_t off, size_t n)



srt_string *ss_dup_substr_u(const srt_string *src, size_t char_off, size_t n)



srt_string *ss_dup_tolower(const srt_string *src)



srt_string *ss_dup_toupper(const srt_string *src)



srt_string *ss_dup_trim(const srt_string *src)



srt_string *ss_dup_w(const wchar_t *src)



srt_string *ss_dup_wn(const wchar_t *src, size_t src_size)



srt_bool ss_empty(const srt_string *s)



srt_string *ss_enc_HEX(srt_string **s, const srt_string *src)



srt_string *ss_enc_b64(srt_string **s, const srt_string *src)



srt_string *ss_enc_esc_dquote(srt_string **s, const srt_string *src)



srt_string *ss_enc_esc_json(srt_string **s, const srt_string *src)



srt_string *ss_enc_esc_squote(srt_string **s, const srt_string *src)



srt_string *ss_enc_esc_url(srt_string **s, const srt_string *src)



srt_string *ss_enc_esc_xml(srt_string **s, const srt_string *src)



srt_string *ss_enc_hex(srt_string **s, const srt_string *src)



srt_string *ss_enc_lz(srt_string **s, const srt_string *src)



srt_string *ss_enc_lzh(srt_string **s, const srt_string *src)



srt_bool ss_encoding_errors(const srt_string *s)



srt_string *ss_erase(srt_string **s, size_t off, size_t n)



srt_string *ss_erase_u(srt_string **s, size_t char_off, size_t n)



size_t ss_find(const srt_string *s, size_t off, const srt_string *tgt)



size_t ss_find_cn(const srt_string *s, size_t off, const char *t, size_t ts)



size_t ss_findb(const srt_string *s, size_t off)



size_t ss_findc(const srt_string *s, size_t off, char c)



size_t ss_findcx(const srt_string *s, size_t off, uint8_t c_min, uint8_t c_max)



size_t ss_findnb(const srt_string *s, size_t off)



size_t ss_findr(const srt_string *s, size_t off, size_t max_off, const srt_string *tgt)



size_t ss_findr_cn(const srt_string *s, size_t off, size_t max_off, const char *t, size_t ts)



size_t ss_findrb(const srt_string *s, size_t off, size_t max_off)



size_t ss_findrc(const srt_string *s, size_t off, size_t max_off, char c)



size_t ss_findrcx(const srt_string *s, size_t off, size_t max_off, uint8_t c_min, uint8_t c_max)



size_t ss_findrnb(const srt_string *s, size_t off, size_t max_off)



size_t ss_findru(const srt_string *s, size_t off, size_t max_off, int c)



size_t ss_findu(const srt_string *s, size_t off, int c)



uint32_t ss_fnv1(const srt_string *s)



uint32_t ss_fnv1a(const srt_string *s)



uint32_t ss_fnv1ar(const srt_string *s, uint32_t fnv, size_t off1, size_t off2)



uint32_t ss_fnv1r(const srt_string *s, uint32_t fnv, size_t off1, size_t off2)



void ss_free(srt_string **s, ...)



char *ss_get_buffer(srt_string *s)



const char *ss_get_buffer_r(const srt_string *s)



size_t ss_get_buffer_size(const srt_string *v)



int ss_getchar(const srt_string *s, size_t *autoinc_off)



size_t ss_grow(srt_string **s, size_t extra_elems)



size_t ss_len(const srt_string *s)



size_t ss_len_u(const srt_string *s)



srt_string *ss_ltrim(srt_string **s)



size_t ss_max(const srt_string *s)



uint32_t ss_mh3_32(const srt_string *s)



uint32_t ss_mh3_32r(const srt_string *s, uint32_t acc, size_t off1, size_t off2)



int ss_ncmp(const srt_string *s1, size_t s1off, const srt_string *s2, size_t n)



int ss_ncmpi(const srt_string *s1, size_t s1off, const srt_string *s2, size_t n)



int ss_popchar(srt_string **s)



int ss_printf(srt_string **s, size_t size, const char *fmt, ...)



int ss_putchar(srt_string **s, int c)



ssize_t ss_read(srt_string **s, FILE *handle, size_t max_bytes)



const srt_string *ss_ref(const srt_string_ref *s_ref)



const srt_string *ss_ref_buf(srt_string_ref *s_ref, const char *buf, size_t buf_size)



const srt_string *ss_refa_buf(const char *buf, size_t buf_size)



srt_string *ss_replace(srt_string **s, size_t off, const srt_string *s1, const srt_string *s2)



size_t ss_reserve(srt_string **s, size_t max_elems)



srt_string *ss_resize(srt_string **s, size_t n, char fill_byte)



srt_string *ss_resize_u(srt_string **s, size_t n, int fill_char)



srt_string *ss_rtrim(srt_string **s)



srt_bool ss_set_turkish_mode(srt_bool enable_turkish_mode)



srt_string *ss_shrink(srt_string **s)



size_t ss_size(const srt_string *s)



size_t ss_split(const srt_string *src, const srt_string *separator, srt_string_ref out_substrings[], size_t max_refs)



const char *ss_to_c(const srt_string *s)



const wchar_t *ss_to_w(const srt_string *s, wchar_t *o, size_t nmax, size_t *n)



srt_string *ss_tolower(srt_string **s)



srt_string *ss_toupper(srt_string **s)



srt_string *ss_trim(srt_string **s)



ssize_t ss_write(FILE *handle, const srt_string *s, size_t offset, size_t bytes)