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 2004/03/17 10:37:44 UTC
DO NOT REPLY [Bug 26886] -
Iconv calcRequiredSize() fails with multibyte encoding like UTF8
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=26886>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=26886
Iconv calcRequiredSize() fails with multibyte encoding like UTF8
------- Additional Comments From anders.hybertz@mobilecohesion.com 2004-03-17 09:37 -------
I suggest to change it to the following
unsigned int IconvLCPTranscoder::calcRequiredSize(const char* const srcText)
{
if( !srcText ) return 0;
unsigned int len( 0 );
unsigned int size( strlen( srcText ) );
for( int i = 0; i < size; ++len )
{
unsigned int retVal( mblen( &srcText[i], MB_CUR_MAX ) );
if( -1 == retVal ) return 0;
i += retVal
}
return len;
}
Which runs over all the chars in he string and count the proper lenght. I'm
not using mbstowcs because it's not considered to be 100% platform independent.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org