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

QSettings incorrectly processes .ini file with UTF-8 Byte Order Mark (BOM)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.4.0 RC
    • 4.7.4, 4.8.4, 5.0.1, 5.1.0 RC1
    • Core: Other
    • None
    • Windows

    Description

      QSettings can not handle .ini files with UTF-8 BOM marker at the beginning (0xEF 0xBB 0xBF). For example, when reading file:

      <EF><BB><BF>[section1]
      foo1=bar1
      [section2]
      foo2=bar2

      the parameters read by QSettings are:
      foo1=bar
      section2/foo2=bar

      i.e. the first section line is ignored. If I insert a blank line at the beginning of the file:

      <EF><BB><BF>
      [section1]
      foo1=bar1
      [section2]
      foo2=bar2

      then QSettings gives the expected result
      section1/foo1=bar
      section2/foo2=bar

      The problem occurs identically in cases when I call setIniCodec("UTF-8") or do not make the call.

      While UTF-8 BOM marker is uncommon and not really useful, some instruments (especially in Windows) create files with it. Well, even Qt Creator supports writing UTF-8 BOM. Ignoring the problem and silently failing is not an option in this case.

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            mbalabin Mikhail Balabin
            Votes:
            7 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes