Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-23139

Problem with the QTextCodec::toUnicode function (no difference between NULL string and EMPTY string)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.7.4, 4.8.2
    • None
    • all

    Description

      Just a little exemple :

      QTextCodec *_code = QTextCodec::codecForName(QString(QLatin1String("Windows-1252")).toLocal8Bit());
      QString _t = _code->toUnicode("", 0);
      

      the isNull() and the isEmpty() method of "_t" returns true or the isNull method must be return false.

      Otherwise :

      QString _t = QString::fromUtf8("", 0);
      

      In this case isNull return false and isEmpty return true. (good result for me).

      if we look into the code of qsimplecodec.cpp in the function convertToUnicode :

      if (len <= 0 || chars == 0)
          return QString();
      

      i think the problem is there and the code should be :

       if (len < 0 ||chars == 0)
           return QString();
       if (len == 0) 
           return QString("");
      

      This bug is very problematic for the database drivers

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            sdnetwork le roy arnaud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes