curl_strnequal(3)

πŸ’– curl_strnequal β€” the case-insensitive string comparison bestie πŸ’–

Okay so this is a libcurl manual page, from the Library Functions Manual β€” and honestly? It's giving "small function, big main character energy" ✨


🌸 NAME 🌸

curl_strnequal β€” compare two strings ignoring case 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <curl/curl.h>

int curl_strnequal(const char *str1, const char *str2, size_t length);

πŸ’… DESCRIPTION πŸ’…

So the curl_strnequal(3) function compares the two strings str1 and str2, and it ignores the case of the characters, periodt. It returns a non-zero (TRUE) integer if the strings are identical. Slay. πŸ’–

This function compares no more than the first length bytes of str1 and str2 β€” lowkey a vibe check on just the beginning of your strings.

And here's the iconic part: this function uses plain ASCII based comparisons, completely disregarding the locale β€” contrary to how strcasecmp and other system case insensitive string comparisons usually work. No cap, it does not care about your locale settings at all. πŸ™ˆ

This function is provided by libcurl to enable applications to compare strings in a truly portable manner. There are no standard portable case insensitive string comparison functions β€” so libcurl said "fine, I'll do it myself" πŸ’€ and this function works on all platforms. Obsessed honestly. 🌈


✨ PROTOCOLS ✨

This functionality affects all supported protocols πŸ¦‹


πŸ”₯ EXAMPLE πŸ”₯

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

Look at it go πŸ₯Ή β€” comparing "compare" against your input over the first 5 bytes.


⭐ AVAILABILITY ⭐

Added in curl 7.1 πŸ‘‘


🧚 RETURN VALUE 🧚

Non-zero if the strings are identical. Zero if they are not. Simple as that, bestie πŸ’œ

Also worth keeping in mind: non-zero here means TRUE, so don't be out here checking == 1, okay? 😭

πŸ’– SEE ALSO πŸ’–


And that's the whole thing, bestie! πŸŽ€ Cute little sign-off: this page comes from libcurl, dated 2026-10-12, and it's blessed by the Library Functions Manual. Go forth and compare strings portably πŸ’…βœ¨

πŸ“¦ where this page comes from