amassari 2004/07/23 14:16:07
Modified: c/src/xercesc/util/Transcoders/Iconv IconvTransService.cpp
Log:
calcRequiredSize assumed all the characters were of the same size (jira#1142) -
Patch by Anders Hybertz
Revision Changes Path
1.16 +11 -10
xml-xerces/c/src/xercesc/util/Transcoders/Iconv/IconvTransService.cpp
Index: IconvTransService.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/util/Transcoders/Iconv/IconvTransService.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- IconvTransService.cpp 5 Feb 2004 18:08:38 -0000 1.15
+++ IconvTransService.cpp 23 Jul 2004 21:16:07 -0000 1.16
@@ -261,15 +261,16 @@
if (!srcText)
return 0;
- unsigned charLen = ::mblen(srcText, MB_CUR_MAX);
- if (charLen == -1)
- return 0;
- else if (charLen != 0)
- charLen = strlen(srcText)/charLen;
-
- if (charLen == -1)
- return 0;
- return charLen;
+ unsigned int len=0;
+ unsigned int size=strlen(srcText);
+ for( unsigned int i = 0; i < size; ++len )
+ {
+ unsigned int retVal=::mblen( &srcText[i], MB_CUR_MAX );
+ if( -1 == retVal )
+ return 0;
+ i += retVal;
+ }
+ return len;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]