wcscasecmp()

QNX SDP8.0C Library ReferenceAPIDeveloper

Compare two wide-character strings, ignoring case

Synopsis:

#include <wchar.h>

int wcscasecmp( const wchar_t * ws1,
                const wchar_t * ws2 );

Arguments:

ws1, ws2
The strings that you want to compare.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The wcscasecmp() function compares two wide-character strings, specified by ws1 and ws2, ignoring the case of the characters.

Returns:

< 0
ws1 is less than ws2.
0
ws1 is equal to ws2.
> 0
ws1 is greater than ws2.

Examples:

#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>

static int compare( const wchar_t * ws1, const wchar_t * ws2 )
{
    int retval;
    
    retval = wcscasecmp( ws1, ws2 );
    if( retval > 0 ) {
        wprintf( "%ls > %ls\n", ws1, ws2 );
    } else if( retval < 0 ) {
        wprintf( "%ls < %ls\n", ws1, ws2 );
    } else {
        wprintf( "%ls == %ls\n", ws1, ws2 );
    }
    
    return retval;
}

int main( void )
{
    const wchar_t * str1 = L"abcdefg";
    const wchar_t * str2 = L"HIJ";
    const wchar_t * str3 = L"Abc";
    const wchar_t * str4 = L"aBCDEfg";

    compare( str1, str2 );
    compare( str1, str3 );
    compare( str1, str4 );
    compare( str1, str1 );
    
    compare( str2, str2 );
    compare( str2, str3 );
    compare( str2, str4 );
    compare( str2, str1 );
    
    return EXIT_SUCCESS;
}

This code produces output that looks like:

abcdefg < HIJ
abcdefg > Abc
abcdefg == aBCDEfg
abcdefg == abcdefg
HIJ == HIJ
HIJ > Abc
HIJ > aBCDEfg
HIJ > abcdefg

Classification:

POSIX 1003.1

Safety:
Cancellation pointNo
Signal handlerYes
ThreadYes
Page updated: