curl_strequal(3)

curl_strequal3

Case insensitive string comparisons

Usage

#include <curl/curl.h>
int curl_strequal(const char *str1, const char *str2);
int curl_strnequal(const char *str1, const char *str2, size_t length);

Overview

The curl_strequal(3) function compares the two strings str1 and str2, ignoring the case of the characters. It returns a non-zero (TRUE) integer if the strings are identical.

The curl_strnequal() function is similar, except it only compares the first length characters of str1.

These functions are provided by libcurl to enable applications to compare strings in a truly portable manner. There are no standard portable case insensitive string comparison functions. These two work on all platforms.

Examples

int main(int argc, char **argv)
{
  const char *name = "compare";
  if(curl_strequal(name, argv[1]))
    printf("Name and input matches\n");
  if(curl_strnequal(name, argv[1], 5))
    printf("Name and input matches in the 5 first bytes\n");
}

Return value

Non-zero if the strings are identical. Zero if they are not.

Releases

155 releases since Mac OS X 10.2; the text changed 18 times.

  1. 10.2–10.2.8
  2. 10.3–10.3.9
  3. 10.4–10.5.8
  4. 10.6–10.6.8
  5. 10.7–10.7.5
  6. 10.8–10.11.6
  7. 10.12–10.12.5
  8. 10.12.6–10.14.6
  9. 10.15–11.5
  10. 12.0.1–12.2
  11. 12.3–12.5
  12. 13.0
  13. 13.1
  14. 13.2
  15. 13.3
  16. 13.4
  17. 13.5–14.1
  18. 14.2–14.4
  19. 14.5–26.5

Availability

Always

From curl 166.0.0.0.1 in macOS 26.5. Parsed by carta from the page's man source.