amassari 2004/01/16 08:34:59 Modified: c/src/xercesc/util/Transcoders/Win32 Win32TransService.cpp Log: In the Win32LCPTranscoder, don't use wcstombs or mbstowcs, as they don't pick up the correct local code page; use the Win32 API using CP_ACP as the code page Revision Changes Path 1.20 +12 -17 xml-xerces/c/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp Index: Win32TransService.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- Win32TransService.cpp 13 Jan 2004 16:34:22 -0000 1.19 +++ Win32TransService.cpp 16 Jan 2004 16:34:59 -0000 1.20 @@ -849,15 +849,10 @@ if (!srcText) return 0; - unsigned charLen = ::mblen(srcText, MB_CUR_MAX); - if (charLen == -1) + int retVal = ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, srcText, -1, NULL, 0); + if (retVal == -1) return 0; - else if (charLen != 0) - charLen = strlen(srcText)/charLen; - - if (charLen == -1) - return 0; - return charLen; + return retVal; } @@ -867,8 +862,8 @@ if (!srcText) return 0; - const unsigned int retVal = ::WideCharToMultiByte(CP_ACP, 0, srcText, -1, NULL, 0, NULL, NULL); - if (retVal == (unsigned int)-1) + int retVal = ::WideCharToMultiByte(CP_ACP, 0, srcText, -1, NULL, 0, NULL, NULL); + if (retVal == -1) return 0; return retVal; } @@ -888,7 +883,7 @@ // Allocate a buffer of that size plus one for the null and transcode retVal = new char[neededLen + 1]; - ::wcstombs(retVal, toTranscode, neededLen + 1); + ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, retVal, neededLen+1, NULL, NULL); // And cap it off anyway just to make sure retVal[neededLen] = 0; @@ -915,7 +910,7 @@ // Allocate a buffer of that size plus one for the null and transcode retVal = (char*) manager->allocate((neededLen + 1) * sizeof(char)); //new char[neededLen + 1]; - ::wcstombs(retVal, toTranscode, neededLen + 1); + ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, retVal, neededLen+1, NULL, NULL); // And cap it off anyway just to make sure retVal[neededLen] = 0; @@ -949,7 +944,7 @@ // Allocate a buffer of that size plus one for the null and transcode retVal = new XMLCh[neededLen + 1]; - ::mbstowcs(retVal, toTranscode, neededLen + 1); + ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)retVal, neededLen + 1); // Cap it off just to make sure. We are so paranoid! retVal[neededLen] = 0; @@ -982,7 +977,7 @@ // Allocate a buffer of that size plus one for the null and transcode retVal = (XMLCh*) manager->allocate((neededLen + 1) * sizeof(XMLCh)); //new XMLCh[neededLen + 1]; - ::mbstowcs(retVal, toTranscode, neededLen + 1); + ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)retVal, neededLen + 1); // Cap it off just to make sure. We are so paranoid! retVal[neededLen] = 0; @@ -1015,7 +1010,7 @@ } // This one has a fixed size output, so try it and if it fails it fails - if (::mbstowcs(toFill, toTranscode, maxChars + 1) == size_t(-1)) + if ( size_t(-1) == ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toTranscode, -1, (LPWSTR)toFill, maxChars + 1) ) return false; return true; } @@ -1040,7 +1035,7 @@ } // This one has a fixed size output, so try it and if it fails it fails - if (::wcstombs(toFill, toTranscode, maxBytes + 1) == size_t(-1)) + if ( size_t(-1) == ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)toTranscode, -1, toFill, maxBytes + 1, NULL, NULL) ) return false; // Cap it off just in case
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]