ba0f462857
Reported by Jean-Yves Burlett, thanks ! (As seen in http://bugs.kde.org/db/31/31330.html)
33 lines
912 B
Plaintext
33 lines
912 B
Plaintext
$OpenBSD: patch-src_tools_qtextcodec_cpp,v 1.1 2002/02/05 17:44:17 espie Exp $
|
|
--- src/tools/qtextcodec.cpp.orig Sat Feb 2 17:46:28 2002
|
|
+++ src/tools/qtextcodec.cpp Sat Feb 2 17:55:35 2002
|
|
@@ -1907,19 +1907,24 @@ QString QSimpleTextCodec::toUnicode(cons
|
|
if(len <= 0)
|
|
return QString::null;
|
|
|
|
- int clen = qstrlen(chars);
|
|
- len = QMIN(len, clen); // Note: NUL ends string
|
|
+ if (chars == NULL)
|
|
+ len = 0;
|
|
|
|
QString r;
|
|
r.setUnicode(0, len);
|
|
QChar* uc = (QChar*)r.unicode(); // const_cast
|
|
const unsigned char * c = (const unsigned char *)chars;
|
|
- for( int i=0; i<len; i++ ) {
|
|
+ int i;
|
|
+ for( i=0; i<len; i++ ) {
|
|
if ( c[i] > 127 )
|
|
uc[i] = unicodevalues[forwardIndex].values[c[i]-128];
|
|
- else
|
|
+ else if ( c[i] != 0 )
|
|
uc[i] = c[i];
|
|
+ else
|
|
+ break;
|
|
}
|
|
+ if ( i < len )
|
|
+ r.truncate(i);
|
|
return r;
|
|
}
|
|
|