curl_strnequal.md (1408B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_strnequal 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_strequal (3) 9 - strcasecmp (3) 10 - strcmp (3) 11 Protocol: 12 - All 13 Added-in: 7.1 14 --- 15 16 # NAME 17 18 curl_strnequal - compare two strings ignoring case 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 int curl_strnequal(const char *str1, const char *str2, size_t length); 26 ~~~ 27 28 # DESCRIPTION 29 30 The curl_strnequal(3) function compares the two strings *str1* and *str2*, 31 ignoring the case of the characters. It returns a non-zero (TRUE) integer if 32 the strings are identical. 33 34 This function compares no more than the first *length* bytes of *str1* and 35 *str2*. 36 37 This function uses plain ASCII based comparisons completely disregarding the 38 locale - contrary to how **strcasecmp** and other system case insensitive 39 string comparisons usually work. 40 41 This function is provided by libcurl to enable applications to compare strings 42 in a truly portable manner. There are no standard portable case insensitive 43 string comparison functions. This function works on all platforms. 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(int argc, char **argv) 51 { 52 const char *name = "compare"; 53 if(curl_strnequal(name, argv[1], 5)) 54 printf("Name and input matches in the 5 first bytes\n"); 55 } 56 ~~~ 57 58 # %AVAILABILITY% 59 60 # RETURN VALUE 61 62 Non-zero if the strings are identical. Zero if they are not.