|
CX Framework
Cross-platform C utility framework
|
Functions | |
| bool | strEq (strref s1, strref s2) |
| bool | strEqi (strref s1, strref s2) |
| int32 | strCmp (strref s1, strref s2) |
| int32 | strCmpi (strref s1, strref s2) |
| bool | strRangeEq (strref str, strref sub, int32 off, uint32 len) |
| bool | strRangeEqi (strref str, strref sub, int32 off, uint32 len) |
| int32 | strRangeCmp (strref str, strref sub, int32 off, uint32 len) |
| int32 | strRangeCmpi (strref str, strref sub, int32 off, uint32 len) |
| bool | strBeginsWith (strref str, strref sub) |
| bool | strBeginsWithi (strref str, strref sub) |
| bool | strEndsWith (strref str, strref sub) |
| bool | strEndsWithi (strref str, strref sub) |
String comparison functions for equality testing and lexicographic ordering. All comparison functions support case-sensitive and case-insensitive variants.
Case-insensitive comparisons use ASCII tolower() and do not properly handle multi-byte UTF-8 characters.
| bool strBeginsWith | ( | strref | str, |
| strref | sub | ||
| ) |
Tests if a string begins with a specific prefix (case-sensitive)
Checks if the first bytes of str match sub. This is equivalent to strRangeEq(str, sub, 0, strLen(sub)).
| str | String to check |
| sub | Prefix to test for |
Example:
| bool strBeginsWithi | ( | strref | str, |
| strref | sub | ||
| ) |
Tests if a string begins with a specific prefix (case-insensitive)
Like strBeginsWith(), but performs case-insensitive comparison. This is an ASCII-only comparison.
| str | String to check |
| sub | Prefix to test for |
Example:
| int32 strCmp | ( | strref | s1, |
| strref | s2 | ||
| ) |
Compares two strings lexicographically (case-sensitive)
Performs a binary comparison of string bytes. This is NOT intended for locale-aware lexical sorting - use a proper collation function for that.
| s1 | First string to compare |
| s2 | Second string to compare |
Example:
| int32 strCmpi | ( | strref | s1, |
| strref | s2 | ||
| ) |
Compares two strings lexicographically (case-insensitive)
Like strCmp(), but performs case-insensitive comparison using tolower(). This is an ASCII-only comparison - multi-byte UTF-8 characters are not properly case-folded.
| s1 | First string to compare |
| s2 | Second string to compare |
Example:
| bool strEndsWith | ( | strref | str, |
| strref | sub | ||
| ) |
Tests if a string ends with a specific suffix (case-sensitive)
Checks if the last bytes of str match sub. This is equivalent to strRangeEq(str, sub, -strLen(sub), strLen(sub)).
| str | String to check |
| sub | Suffix to test for |
Example:
| bool strEndsWithi | ( | strref | str, |
| strref | sub | ||
| ) |
Tests if a string ends with a specific suffix (case-insensitive)
Like strEndsWith(), but performs case-insensitive comparison. This is an ASCII-only comparison.
| str | String to check |
| sub | Suffix to test for |
Example:
| bool strEq | ( | strref | s1, |
| strref | s2 | ||
| ) |
Tests if two strings are equal (case-sensitive)
This is slightly faster than strCmp() when you only need to check equality rather than ordering. Performs an early-out optimization by comparing lengths first.
| s1 | First string to compare |
| s2 | Second string to compare |
Example:
| bool strEqi | ( | strref | s1, |
| strref | s2 | ||
| ) |
Tests if two strings are equal (case-insensitive)
Like strEq(), but performs case-insensitive comparison using tolower(). This is an ASCII-only comparison - multi-byte UTF-8 characters are not properly case-folded.
| s1 | First string to compare |
| s2 | Second string to compare |
Example:
| int32 strRangeCmp | ( | strref | str, |
| strref | sub, | ||
| int32 | off, | ||
| uint32 | len | ||
| ) |
Compares a substring range with another string (case-sensitive)
Compares up to len bytes of str starting at offset off with sub. Negative offsets are relative to the end of str.
| str | String containing the range to compare |
| sub | String to compare against |
| off | Starting offset in str (negative = from end) |
| len | Maximum number of bytes to compare |
Example:
| int32 strRangeCmpi | ( | strref | str, |
| strref | sub, | ||
| int32 | off, | ||
| uint32 | len | ||
| ) |
Compares a substring range with another string (case-insensitive)
Like strRangeCmp(), but performs case-insensitive comparison. This is an ASCII-only comparison.
| str | String containing the range to compare |
| sub | String to compare against |
| off | Starting offset in str (negative = from end) |
| len | Maximum number of bytes to compare |
| bool strRangeEq | ( | strref | str, |
| strref | sub, | ||
| int32 | off, | ||
| uint32 | len | ||
| ) |
Tests if a substring range equals another string (case-sensitive)
Compares up to len bytes of str starting at offset off with sub. Negative offsets are relative to the end of str. If the offset is out of bounds or the ranges don't match in length (after clamping), returns false.
| str | String containing the range to compare |
| sub | String to compare against |
| off | Starting offset in str (negative = from end) |
| len | Maximum number of bytes to compare |
Example:
| bool strRangeEqi | ( | strref | str, |
| strref | sub, | ||
| int32 | off, | ||
| uint32 | len | ||
| ) |
Tests if a substring range equals another string (case-insensitive)
Like strRangeEq(), but performs case-insensitive comparison. This is an ASCII-only comparison.
| str | String containing the range to compare |
| sub | String to compare against |
| off | Starting offset in str (negative = from end) |
| len | Maximum number of bytes to compare |