Files
vystem-b/docs/shelter/std/strings.md
2026-05-27 19:34:54 +02:00

1.2 KiB

Strings operations

The Shelter standard library provides basic strings operations primitives, defined in shelter/lib/include/std/string.h and implemented inside shelter/lib/src/std/string.c:

  • sh_string_len(char *str): return the length of a null terminated string
  • sh_string_compare(char *str1,char* str2,sh_uint64 length): compare two null terminated string, both strings must not exceed the provided length. return SH_TRUE if both strings are equal on the provided length
  • sh_string_find_char(char *str,char character): return the index of the first occurence of the provide character into the string, return SH_UINT64_MAX if not found or error
  • sh_string_find(char *str,char *substr): return the index of the start of the first occurence of the provided substring into the string, return SH_UINT64_MAX if not found or error
  • sh_string_substring(char *source_str,sh_uint64 start_index,sh_uint64 length,char *output): copy a substring from a string to another string, and return the pointer to the new null terminated string (aka the provided output pointer). Return SH_NULLPTR if error
  • sh_string_to_uint64(char *str): convert a string to a sh_uint64 and return this sh_uint64