Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Win-1251 codepage and QIBASE driver
QtWS25 Last Chance

Win-1251 codepage and QIBASE driver

Scheduled Pinned Locked Moved General and Desktop
15 Posts 6 Posters 8.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dmytro
    wrote on last edited by
    #5

    windows-1251 and Windows-1251 are do not work
    In this case wrote that character set is not defined. See below

    "errors text":http://hin.dp.ua/files/down/QIBASE_fig2.png

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #6

      I don't know what's going on. It's weird that you get an error message about missing sqlite support when you are working with an ibase database.

      Maybe "CP1251" works for the encoding. That's a known alias for windows-1251 in QTextCodec.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dmytro
        wrote on last edited by
        #7

        It’s really weird, but using “CP1251” such as "Windows-1251" returned error, the same error.
        Using "WIN1251" do not returned error, but not returned correct symbols.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #8

          According to "QIBASE Unicode Support and Text Encoding":http://doc.qt.nokia.com/4.7/sql-driver.html#qibase-unicode-support-and-text-encoding it falls back to Unicode when the encoding you request is not available (not availabel in QTextCodec, according to a quick look to the source code of the qsql_ibase plugin).

          CP1251 and Windows-1251 are valid in QTextCodec but may not be correct for IBase; on the other hand WIN1251 and WIN-1251 may be correct for IBase but are not valid for QTextCodec. So this seems to be a loose-loose situation.

          One solution might be to create your own QTextCodec according to the "API docs":http://doc.qt.nokia.com/4.7/qtextcodec.html#creating-your-own-codec-class. I'd leave all the functionality to a codec you get with codecForName(), saved as a class-private pointer to your new codec and delegate all methods to the respective methods of the worker codec (except the name/aliases of course).

          Or you add another alias to src/corelib/codecs/qsimplecodec.cpp and compile your Qt libs manually (i.e. not use the precompiled ones).

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dmytro
            wrote on last edited by
            #9

            thanks to all

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Dmytro
              wrote on last edited by
              #10

              You mean it?
              in file src/corelib/codecs/qsimplecodec.cpp
              @
              ...
              { "windows-1251", { "CP1251", "WIN1251", "WIN-1251", 0 }, 2251,
              { 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
              0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
              ...
              @

              And in this case, along with my program I will must to distribute own, modified library? Isn't it?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #11

                Yes, that's right. Or you go with a custom text codec plugin. In that case you only need to distribute this one, without modifying the base Qt libs.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  michael.goddard
                  wrote on last edited by
                  #12

                  Did the above qsimplecodec.cpp change fix your problem?

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Dmytro
                    wrote on last edited by
                    #13

                    I was not able to compile: (
                    Too many errors and time less to complete the task.
                    Apparently there have been failures in setting up paths.
                    I'm using ODBC driver now.
                    Unfortunately.

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      Wolf P.
                      wrote on last edited by
                      #14

                      Seems to be reported as bug "QTBUG-15608":http://bugreports.qt.nokia.com/browse/QTBUG-15608

                      1 Reply Last reply
                      0
                      • Dmitriy KretD Offline
                        Dmitriy KretD Offline
                        Dmitriy Kret
                        wrote on last edited by
                        #15

                        in the file C:\Qt\Qt5.7.0\5.7\Src\qtbase\src\sql\drivers\ibase\qsql_ibase.cpp
                        find the code:
                        // Use UNICODE_FSS when no ISC_DPB_LC_CTYPE is provided
                        if (encString.isEmpty())
                        encString = QLatin1String("UNICODE_FSS");
                        else {
                        d->tc = QTextCodec::codecForName(encString.toLocal8Bit());
                        if (!d->tc) {
                        qWarning("Unsupported encoding: %s. Using UNICODE_FFS for ISC_DPB_LC_CTYPE.", encString.toLocal8Bit().constData());
                        encString = QLatin1String("UNICODE_FSS"); // Fallback to UNICODE_FSS
                        }
                        }
                        to redo:
                        // Use UNICODE_FSS when no ISC_DPB_LC_CTYPE is provided
                        if (encString.isEmpty())
                        encString = QLatin1String("UNICODE_FSS");
                        else
                        {
                        QString temp = QLatin1String("WIN1251");
                        if(encString == temp)
                        {
                        qDebug()<<"win1251 detected";
                        temp = QLatin1String("windows-1251");
                        d->tc = QTextCodec::codecForName(temp.toLocal8Bit());
                        }
                        else
                        {
                        d->tc = QTextCodec::codecForName(encString.toLocal8Bit());
                        if (!d->tc)
                        {
                        qWarning("Unsupported encoding: %s. Using UNICODE_FFS for ISC_DPB_LC_CTYPE.", encString.toLocal8Bit().constData());
                        encString = QLatin1String("UNICODE_FSS"); // Fallback to UNICODE_FSS
                        }
                        }
                        }

                        compile your driver as shown in the documentation:
                        cd $QTDIR/qtbase/src/plugins/sqldrivers/ibase
                        qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib" ibase.pro
                        make
                        move dll from C:\Qt\Qt5.7.0\5.7\Src\qtbase\plugins\sqldrivers to C:\Qt\Qt5.7.0\5.7\mingw53_32\plugins\sqldrivers
                        enjoy it

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved