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

Non-breaking spaces in raw string literals are silently converted to plain spaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • Qt Creator 9.0.0
    • Qt Creator 4.8.0
    • All Other Issues
    • None
    • All
    • c6b6a6a0773275a7c1b803bef62dc37dc5fe010e (qt-creator/qt-creator/4.9)

    Description

      This seems to be reopening QTCREATORBUG-17875 which was closed and shunted across to QTBUG-56538 without actually addressing the original issue.

      Opening a file created in a different editor (which handles such characters without issue) which contains non-breaking spaces shows them in the Qt Creator editor as visually different when white-spaces are set to be visual. Any changes to the file thought causes it to be saved which get them silently converted to plain spaces and when used in string literals this can break previously pre-formatted text. 

      Similarly, while it is possible to paste into Qt Creator such texts they will get modified without warning when the file is saved.

      This is problematic as it is can break legitimate usages of this character. For instance when it is intended as part of a string literal to keep an introducer word (one followed by a colon) or label adjacent to a value. For a somewhat artificial instance, "Douglas Adams's best known answer was: 42."

      Please find attached a simple application to demonstrate this.  If compiled and run without editing all three labels will keep the "this:" and "that" words together as the size of the application is changed.  Those two words in all three sample texts are separated by three non-breaking spaces which were entered into the text displayed in the three labels in three different ways. The first however uses the raw characters directly in the string literal and if the mainwindow.cpp is modifed in anyway so as to cause it to be saved from within the Qt Creator IDE then those characters will be lost cause the text to behave differently (as they are now just plain spaces without the non-break effect) as show in the attached image.

       

      Attachments

        1. non_breaking_spaces_in_qtcreator.tgz
          2 kB
          Stephen Lyons
        2. Screenshot_20190226_195204.png
          79 kB
          Stephen Lyons

        Issue Links

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

          Activity

            People

              con Eike Ziller
              slysven Stephen Lyons
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes