You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2008/03/11 10:17:24 UTC

svn commit: r635858 - /xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp

Author: amassari
Date: Tue Mar 11 02:17:23 2008
New Revision: 635858

URL: http://svn.apache.org/viewvc?rev=635858&view=rev
Log:
When looking for the best encoding, match both char size and endianness

Modified:
    xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp

Modified: xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp?rev=635858&r1=635857&r2=635858&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp Tue Mar 11 02:17:23 2008
@@ -186,7 +186,7 @@
 // Convert "native unicode" character into XMLCh
 void    IconvGNUWrapper::mbcToXMLCh (const char *mbc, XMLCh *toRet) const
 {
-    if (fUBO == LITTLE_ENDIAN) {
+    if (fUBO == BYTE_ORDER) {
         if (fUChSize == sizeof(XMLCh))
             *toRet = *((XMLCh*) mbc);
         else if (fUChSize == 2) {
@@ -206,7 +206,7 @@
 // Convert XMLCh into "native unicode" character
 void    IconvGNUWrapper::xmlChToMbc (XMLCh xch, char *mbc) const
 {
-    if (fUBO == LITTLE_ENDIAN) {
+    if (fUBO == BYTE_ORDER) {
         if (fUChSize == sizeof(XMLCh)) {
             memcpy (mbc, &xch, fUChSize);
             return;
@@ -417,10 +417,10 @@
 
     // Select the native unicode characters encoding schema
     const IconvGNUEncoding    *eptr;
-    // first - try to use the schema with character size, equil to XMLCh
+    // first - try to use the schema with character size equal to XMLCh, and same endianness
     for (eptr = gIconvGNUEncodings; eptr->fSchema; eptr++)
     {
-        if (eptr->fUChSize != sizeof(XMLCh))
+        if (eptr->fUChSize != sizeof(XMLCh) || eptr->fUBO != BYTE_ORDER)
             continue;
 
         // try to create conversion descriptor
@@ -575,23 +575,21 @@
     ArrayJanitor<char> janBuf(encLocal, manager);
     iconv_t    cd_from, cd_to;
 
-    {
-        cd_from = iconv_open (fUnicodeCP, encLocal);
-        if (cd_from == (iconv_t)-1) {
-            resValue = XMLTransService::SupportFilesNotFound;
-            return NULL;
-        }
-        cd_to = iconv_open (encLocal, fUnicodeCP);
-        if (cd_to == (iconv_t)-1) {
-            resValue = XMLTransService::SupportFilesNotFound;
-            iconv_close (cd_from);
-            return NULL;
-        }
-        newTranscoder = new (manager) IconvGNUTranscoder (encodingName,
-                             blockSize,
-                             cd_from, cd_to,
-                             uChSize(), UBO(), manager);
+    cd_from = iconv_open (fUnicodeCP, encLocal);
+    if (cd_from == (iconv_t)-1) {
+        resValue = XMLTransService::SupportFilesNotFound;
+        return NULL;
+    }
+    cd_to = iconv_open (encLocal, fUnicodeCP);
+    if (cd_to == (iconv_t)-1) {
+        resValue = XMLTransService::SupportFilesNotFound;
+        iconv_close (cd_from);
+        return NULL;
     }
+    newTranscoder = new (manager) IconvGNUTranscoder (encodingName,
+                         blockSize,
+                         cd_from, cd_to,
+                         uChSize(), UBO(), manager);
     if (newTranscoder)
         resValue = XMLTransService::Ok;
     return newTranscoder;



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