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 bu...@apache.org on 2001/06/21 09:13:15 UTC

[Bug 2258] New: - Bug in Iconv and Iconv390

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2258

*** shadow/2258	Thu Jun 21 00:13:15 2001
--- shadow/2258.tmp.8629	Thu Jun 21 00:13:15 2001
***************
*** 0 ****
--- 1,60 ----
+ +============================================================================+
+ | Bug in Iconv and Iconv390                                                  |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 2258                        Product: Xerces-C                |
+ |       Status: NEW                         Version: 1.4                     |
+ |   Resolution:                            Platform: Sun                     |
+ |     Severity: Critical                 OS/Version: Solaris                 |
+ |     Priority: Other                     Component: Utilities               |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: xerces-c-dev@xml.apache.org                                  |
+ |  Reported By: mkopp@ftisoft.at                                             |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ 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++;
+     }
+     if (n == maxChars)
+ 	return 0;
+     else
+ 	return (int) ( towupper(*cptr1) - towupper(*cptr2) );
+ 
+ This is how the Iconv400, Windows and ICU are doing it.
\ No newline at end of file

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