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

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

    XMLWordPrintable

Details

    • ae6681673eb5c7768070cad61f483d2a5405dc9e

    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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              kio Günter Woigk
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: