Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28064

Qt Creator replaces legitimate UTF-8 characters (even inside strings) when saving

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Not Evaluated Not Evaluated
    • None
    • Qt Creator 7.0.2
    • Editors
    • None

      Problem:

      With UTF-8 source code files UTF-8 characters can be used directly in code. Usually they are most likely to be used in string literals. GCC (and i guess also other compilers) have no problem compiling source code with UTF-8 characters.

      Unfortunately Qt Creator replaces (at least) the non-breaking space "\u00A0" when not used as an escaped character, but directly as UTF-8 character in the source file.

      Steps to reproduce:

      Create or edit a source file with a different editor and add a non-breaking space (Unicode 00A0) in a string literal.

      Open the file in Qt Creator, change anything and save the file.

      Expected behaviour:

      The not changed parts of the file are not altered and saved as they were before.

      Actual behaviour:
      The non-breaking spaces (UTF-8 encoded 0xC2A0) get changed to normal spaces (UTF-8  / ASCII encoded 0x20).

      More Information:

      The default encoding in my Qt Creator is set to UTF-8. I also tried to disable the "clean whitespace" option of the editor (thinking that might could cause it), but this changed nothing.

      Example:

      See attached pictures before.png and after.png for a hex editor view of a source file before and after saving it with Qt Creator. The source file in the state of before.png is attached as main.cpp

        1. after.png
          after.png
          64 kB
        2. before.png
          before.png
          62 kB
        3. main.cpp
          0.2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            davschul David Schulz
            markus_s Markus Steinhilber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes