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

moc compiler split multibyte UTF-8 characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.15.2, 6.2.2, 6.8.0
    • Build tools: moc
    • None

      I have the class with Q_CLASSINFO with text in utf-8 encodings. Some of the characters are single-byte, and others are multi-bytes. MRE:

      class Foo : public QObject
      {
          Q_OBJECT
      
          Q_CLASSINFO("foo", "1ффффффффффффффффффффффффффффффффффффффффффффффф");
      ...
      }
      

      When i try to compile this class, compiler says:

      moc_foo.cpp:40:75: warning: illegal character encoding in string literal [-Winvalid-source-encoding]
          "1фффффффффффффффффффффффффффффффффф<D1>"
                                              ^~~~
      

      This happens because the compiler split the two-byte utf-8 character and places bytes in different lines. Content of the moc_foo.cpp:

      constexpr auto qt_meta_stringdata_CLASSFooENDCLASS = QtMocHelpers::stringData(
          "Foo",
          "foo",
          "1фффффффффффффффффффффффффффффффффф�"
          "�фффффффффффф"
      );
      
      

      It would be correct to split strings on character boundaries rather than byte boundaries. Or not to split at all.

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

            fabiankosmale Fabian Kosmale
            chabapok Alexander
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes