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 π
curl_strequal(3)β the sibling function, highkey its other half πstrcasecmp(3)strcmp(3)
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
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms