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

QWindowsLocalCodec::canEncode() always succeeds

    XMLWordPrintable

Details

    Description

      Write a code that will check to see if it can convert a UTF16 string into MultiByte in the current locale is not possible.

      QTextCodec::canEncode() always succeeds because:

      This code:

      QByteArray QWindowsLocalCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const 
      { 
          return qt_winQString2MB(uc, len); 
      } 
      

      does not use the converter state's 'invalidChars' param to be set to true if characters are replaced.

      Edit: Testcase:

      assert(!QTextCodec::codecForName("ASCII")->canEncode(QString::fromUtf8("t\xC3\xB6")));
      

      It should be false since "tö" is encoded as "t?" with that codec.

      Attachments

        For Gerrit Dashboard: QTBUG-6925
        # Subject Branch Project Status CR V

        Activity

          People

            cnn Qt Core & Network
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes