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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 4.7.4, 4.8.4, 5.0.1, 5.1.0 RC1
    • Fix Version/s: 5.4.0 RC
    • Component/s: Core: Other
    • Labels:
      None
    • Environment:
      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

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

          Activity

            People

            Assignee:
            laknoll Lars Knoll
            Reporter:
            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