--- /home/derhally/home/xml-xerces/c/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp	Mon Jul 29 11:28:46 2002
+++ ./Win32TransService.cpp	Mon Nov  4 14:51:09 2002
@@ -164,7 +164,14 @@
 {
     // Transcode the name to Unicode and store that copy
     const unsigned int srcLen = strlen(encodingName);
-    const unsigned int targetLen = ::mbstowcs(0, encodingName, srcLen);
+    unsigned int targetLen;
+    
+    #if defined(XML_METROWERKS)
+    	targetLen = ::mbswcslen(encodingName, srcLen);
+    #else
+     	targetLen = ::mbstowcs(0, encodingName, srcLen);
+    #endif
+    
     fEncodingName = new XMLCh[targetLen + 1];
     ::mbstowcs(fEncodingName, encodingName, srcLen);
     fEncodingName[targetLen] = 0;
@@ -396,8 +403,16 @@
         if (isAlias(encodingKey, aliasBuf, nameBufSz))
         {
             const unsigned int srcLen = strlen(aliasBuf);
-            const unsigned int targetLen = ::mbstowcs(0, aliasBuf, srcLen);
-            XMLCh* uniAlias = new XMLCh[targetLen + 1];
+            unsigned int targetLen = -1;
+            XMLCh* uniAlias = 0;
+            
+            #if defined(XML_METROWERKS)
+    			targetLen = ::mbswcslen(aliasBuf, srcLen);
+		    #else
+				targetLen = ::mbstowcs(0, aliasBuf, srcLen);
+            #endif
+            
+            uniAlias = new XMLCh[targetLen + 1];
             ::mbstowcs(uniAlias, aliasBuf, srcLen);
             uniAlias[targetLen] = 0;
             _wcsupr(uniAlias);
@@ -407,8 +422,16 @@
             if (aliasedEntry)
             {
                 const unsigned int srcLen = strlen(nameBuf);
-                const unsigned int targetLen = ::mbstowcs(0, nameBuf, srcLen);
-                XMLCh* uniName = new XMLCh[targetLen + 1];
+                unsigned int targetLen = -1;
+                XMLCh* uniName = 0;
+                
+	            #if defined(XML_METROWERKS)
+	    			targetLen = ::mbswcslen(nameBuf, srcLen);
+			    #else
+					targetLen = ::mbstowcs(0, nameBuf, srcLen);
+	            #endif
+	            
+	             uniName = new XMLCh[targetLen + 1];
                 ::mbstowcs(uniName, nameBuf, srcLen);
                 uniName[targetLen] = 0;
                 _wcsupr(uniName);
@@ -821,7 +844,15 @@
     if (!srcText)
         return 0;
 
-    const unsigned int retVal = ::mbstowcs(0, srcText, 0);
+    unsigned int retVal = -1;
+    
+    #if defined(XML_METROWERKS)
+    	const unsigned int srcLen = strlen(srcText);
+    	retVal = ::mbswcslen(srcText, srcLen);
+    #else
+     	retVal = ::mbstowcs(0, srcText, 0);
+    #endif
+
     if (retVal == (unsigned int)-1)
         return 0;
     return retVal;
@@ -833,7 +864,15 @@
     if (!srcText)
         return 0;
 
-    const unsigned int retVal = ::wcstombs(0, srcText, 0);
+    unsigned int retVal = -1;
+    
+    #if defined(XML_METROWERKS)
+    	const unsigned int srcLen = ::wcslen(srcText);
+    	retVal = ::wcsmbslen(srcText, srcLen);
+    #else
+     	retVal = ::wcstombs(0, srcText, 0);
+    #endif
+    
     if (retVal == (unsigned int)-1)
         return 0;
     return retVal;
@@ -878,7 +917,16 @@
     if (*toTranscode)
     {
         // Calculate the buffer size required
-        const unsigned int neededLen = ::mbstowcs(0, toTranscode, 0);
+        unsigned int neededLen = -1;
+        const unsigned int srcLen = strlen(toTranscode);
+        
+        #if defined(XML_METROWERKS)
+	    	neededLen = ::mbswcslen(toTranscode, srcLen);
+	    #else
+	     	neededLen = ::mbstowcs(0, toTranscode, srcLen);
+	    #endif
+	    
+
         if (neededLen == (unsigned int)-1)
             return 0;
 
