You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Michael Kopp <mk...@ftisoft.at> on 2001/06/18 16:32:11 UTC

Bug in Iconv and Iconv390

Hi guys,

	Xerces-C: 1.4.0
	OS: NT4 SP6a,
		 Sun Solaris 6,7,8
		 os390
	Compiler: VC6 (NT)
		         Sun Workshop Forte 4, 5 and 6U1

The compareNIString seems to compare one char to much:

    unsigned int  n = 0;
    const XMLCh* cptr1 = comp1;
    const XMLCh* cptr2 = comp2;

    while ( (*cptr1 != 0) && (*cptr2 != 0) && (n < maxChars) )
    {
        wint_t wch1 = towupper(*cptr1);
        wint_t wch2 = towupper(*cptr2);
        if (wch1 != wch2)
            break;

        cptr1++;
        cptr2++;
        n++;
    }
    return (int) ( towupper(*cptr1) - towupper(*cptr2) );

When I want to compare only 1 character it will return the difference
between to second ones of the provided strings!!
The correct code should look like the following:

   unsigned int  n = 0;
    const XMLCh* cptr1 = comp1;
    const XMLCh* cptr2 = comp2;

    while ( (*cptr1 != 0) && (*cptr2 != 0) && (n < maxChars) )
    {
        wint_t wch1 = towupper(*cptr1);
        wint_t wch2 = towupper(*cptr2);
        if (wch1 != wch2)
            return int(wch1) - int(wch2);

        cptr1++;
        cptr2++;
        n++;
    }
    return 0;

This is how the Iconv400, Windows and ICU are doing it.

Bye
Mike


Michael Kopp
Financial Technologies International, Inc 
Development Center Austria 
A-4066 Pasching, Plus-Kaufstr.7, P.O. Box 89 
Tel +43 (7229) 76656-23. Fax -99, E-mail: mailto:mkopp@ftisoft.at
http://www.ftisoft.at 

This message is for the named person's use only.  It may contain
confidential, proprietary or legally privileged information.  No
confidentiality or privilege is waived or lost by any erroneous
transmission. If you receive this message in error, please immediately
destroy it and notify the sender.  You must not, directly or indirectly,
use, disclose, distribute, or copy any part of this message if you are not
the intended recipient.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org