diff -Naur qt-x11-free-3.0.2.orig/src/codecs/qtextcodec.cpp qt-x11-free-3.0.2/src/codecs/qtextcodec.cpp --- qt-x11-free-3.0.2.orig/src/codecs/qtextcodec.cpp Mon Feb 18 15:46:29 2002 +++ qt-x11-free-3.0.2/src/codecs/qtextcodec.cpp Tue Mar 12 12:17:01 2002 @@ -424,19 +424,21 @@ // returns a string cotnaining the letters and numbers from input, // with a space separating run of a character class. e.g. "iso8859-1" // becomes "iso 8859 1" -static QString lettersAndNumbers( const char * input ) +static QCString lettersAndNumbers( const char * input ) { - QString result; - QChar c; + QCString result; + QChar c, n; while( input && *input ) { - c = *input; + c.setCell(*input); + c.setRow(0); if ( c.isLetter() || c.isNumber() ) - result += c.lower(); + result += c.lower().cell(); if ( input[1] ) { // add space at character class transition, except // transition from upper-case to lower-case letter - QChar n( input[1] ); + n.setCell(input[1]); + n.setRow(0); if ( c.isLetter() && n.isLetter() ) { if ( c == c.lower() && n == n.upper() ) result += ' '; @@ -464,8 +466,8 @@ // if the letters and numbers are the same, we have an "almost" // perfect match. - QString h( lettersAndNumbers( hint ) ); - QString n( lettersAndNumbers( name ) ); + QCString h( lettersAndNumbers( hint ) ); + QCString n( lettersAndNumbers( name ) ); if ( h == n ) return qstrlen( hint )-1; @@ -1540,19 +1542,22 @@ QString QTextCodecFromIODDecoder::toUnicode(const char* chars, int len) { - const uchar* uchars = (const uchar*)chars; QString result; - while (len--) { - QMultiByteUnicodeTable& t = mb[*uchars]; - if ( t.multibyte ) { - // Chained multi-byte - mb = t.multibyte; - } else { - if ( t.unicode ) - result += QChar(t.unicode); - mb=codec->to_unicode_multibyte; + if(chars) { + const uchar* uchars = (const uchar*)chars; + result.setLength(0); + while (len--) { + QMultiByteUnicodeTable& t = mb[*uchars]; + if ( t.multibyte ) { + // Chained multi-byte + mb = t.multibyte; + } else { + if ( t.unicode ) + result += QChar(t.unicode); + mb=codec->to_unicode_multibyte; + } + uchars++; } - uchars++; } return result; } @@ -2262,26 +2267,30 @@ QString QSimpleTextCodec::toUnicode(const char* chars, int len) const { - if ( len <= 0 || chars == 0 ) - return QString::null; - - const unsigned char * c = (const unsigned char *)chars; - int i; - - for ( i = 0; i < len; i++ ) { - if ( c[i] == '\0' ) - len = i; - } - QString r; - r.setUnicode(0, len); - QChar* uc = (QChar*)r.unicode(); // const_cast - for ( i = 0; i < len; i++ ) { - if ( c[i] > 127 ) - uc[i] = unicodevalues[forwardIndex].values[c[i]-128]; - else - uc[i] = c[i]; + if (chars) { + const unsigned char * c = (const unsigned char *)chars; + int i; + + for ( i = 0; i < len; i++ ) + if ( c[i] == '\0' ) len = i; + + if( len<=0 ) + r.setLength(0); + else { + r.setUnicode(0, len); + QChar* uc = (QChar*)r.unicode(); // const_cast + + for ( i = 0; i < len; i++ ) { + if ( c[i] > 127 ) + uc[i] = unicodevalues[forwardIndex].values[c[i]-128]; + else { + uc[i].setCell( c[i] ); + uc[i].setRow(0); + } + } + } } return r; } @@ -2448,10 +2457,28 @@ QString QLatin1Codec::toUnicode(const char* chars, int len) const { - if(len <= 0) - return QString::null; + QString r; - return QString::fromLatin1(chars, len); + if (chars) { + const unsigned char * c = (const unsigned char *)chars; + int i; + + for ( i = 0; i < len; i++ ) + if ( c[i] == '\0' ) len = i; + + if( len<=0 ) + r.setLength(0); + else { + r.setUnicode(0, len); + QChar* uc = (QChar*)r.unicode(); // const_cast + + for ( i = 0; i < len; i++ ) { + uc[i].setCell( c[i] ); + uc[i].setRow(0); + } + } + } + return r; }