ascii_casecmp


Description:

[ CCode ( cname = "g_ascii_strcasecmp" ) ]
public int ascii_casecmp (string s2)

Compare two strings, ignoring the case of ASCII characters.

Unlike the BSD `strcasecmp()` function, this only recognizes standard ASCII letters and ignores the locale, treating all non-ASCII bytes as if they are not letters.

This function should be used only on strings that are known to be in encodings where the bytes corresponding to ASCII letters always represent themselves. This includes UTF-8 and the ISO-8859-* charsets, but not for instance double-byte encodings like the Windows Codepage 932, where the trailing bytes of double-byte characters include all ASCII letters. If you compare two CP932 strings using this function, you will get false matches.

Both s1 and s2 must be non-`NULL`.

Example: Compare strings, ignoring the case:

public static int main (string[] args) {
string str1 = "YOU WILL OBEY THE DALEKS!";
string str2 = "You will obey the daleks!";
int res = str1.ascii_casecmp (str2);

// Output: ``0``
print ("%d\n", res);
return 0;
}

valac --pkg glib-2.0 string.ascii_casecmp.vala

Parameters:

s2

string to compare with s1

s1

string to compare with s2

Returns:

0 if the strings match, a negative value if s1 < s2, or a positive value if s1 > s2