Skip to content
StrCmpIgnoreCase

StrCmpIgnoreCase

Description

Case-insensitive (ASCII) variants of the StrCmp family. Non-ASCII bytes are compared verbatim; there is no Unicode case folding.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        // Equal under ASCII case folding.
        bool ok = StrCmpIgnoreCase(&hello_lc, &hello_uc) == 0;
        ok      = ok && StrCmpIgnoreCase(&hello_lc, &hello_mc) == 0;
        // Equal under ASCII case folding.
        bool ok = StrCmpIgnoreCase(&hello_lc, &hello_uc) == 0;
        ok      = ok && StrCmpIgnoreCase(&hello_lc, &hello_mc) == 0;
    
        // 'h' lowers to 'h' (0x68), 'w' to 'w' (0x77); negative.
    
        // 'h' lowers to 'h' (0x68), 'w' to 'w' (0x77); negative.
        ok = ok && StrCmpIgnoreCase(&hello_lc, &world) < 0;
        // Reverse direction.
        ok = ok && StrCmpIgnoreCase(&world, &hello_uc) > 0;
        ok = ok && StrCmpIgnoreCase(&hello_lc, &world) < 0;
        // Reverse direction.
        ok = ok && StrCmpIgnoreCase(&world, &hello_uc) > 0;
    
        // Length mismatch: hello < hellox under case-insensitive compare.
    
        // Length mismatch: hello < hellox under case-insensitive compare.
        ok = ok && StrCmpIgnoreCase(&hello_lc, &hello_x) < 0;
    
        // Cstr / Zstr variants share the same underlying helper.
        Str non_ascii_a = StrInitFromZstr("ABC\xC0", &alloc);
        Str non_ascii_b = StrInitFromZstr("abc\xC0", &alloc);
        ok              = ok && StrCmpIgnoreCase(&non_ascii_a, &non_ascii_b) == 0;
    
        StrDeinit(&hello_lc);
Last updated on