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

QtCreator replaces non breaking spaces with "normal" spaces in documents

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • Qt Creator 9.0.0-beta1
    • Qt Creator 4.1.0
    • Editors
    • None

    Description

      A non-breaking space (character 0xA0 or ALT+Space on Mac keyboard) typed into a source text is always replaced by a simple space. While this seems a good idea for any place where c++ expects white space (and cannot handle a nbsp) this also happens in string literals, like char* z=" "; (with a nbsp between " and "). This modifies behavior of the resulting program. This also happens if the code snippet is pasted in from the clipboard. This is a problem because you cannot tell by a look at the source whether it is a nbsp or a simple space.
      Minimal example of the issue:

      #include <QTextDocument>
      
      int main()
      {
          QString text (QChar::Nbsp);
          QTextDocument doc(text);
          QString plainText = doc.toPlainText();
      
          return plainText != text;
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              davschul David Schulz
              simonlangevin Simon Langevin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes