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

Incompatibility in QTextCodec between Qt5 and Qt6 (lack of BOM)

    XMLWordPrintable

Details

    • Linux/Wayland, Windows
    • dd0ddad63 (dev), b183f7e84 (6.7), 3d0b5d42e (tqtc/lts-6.5)
    • Foundation PM Staging

    Description

      Reproducer is attached.
      QTextCodec::fromUnicode in Qt6 (Qt5 compat module) gives a different result from Qt5.

      In encoding from Unicode to UTF-16LE, the outputs are as shown below:

      Qt 5.15.16

      "\xFF\xFE""1\x00""2\x00""3\x00""4\x00""5\x00"    <== "12345" encoded by QTextCodec
      "\xFF\xFE""1\x00""2\x00""3\x00""4\x00""5\x00"    <== by QTextEncoder
      "\xFF\xFE""a\x00""b\x00""c\x00""d\x00""e\x00"    <== "abcde" encoded by QTextCodec
      "\xFF\xFE""a\x00""b\x00""c\x00""d\x00""e\x00"    <== by QTextEncoder

      Qt 6.6.2

      "1\x00""2\x00""3\x00""4\x00""5\x00"              <== "12345" encoded by QTextCodec
      "\xFF\xFE""1\x00""2\x00""3\x00""4\x00""5\x00"    <== by QTextEncoder
      "a\x00""b\x00""c\x00""d\x00""e\x00"              <== "abcde" encoded by QTextCodec
      "\xFF\xFE""a\x00""b\x00""c\x00""d\x00""e\x00"    <== by QTextEncoder

      As shown here, BOM (Byte Order Mark) is missing in QTextCodec's output in Qt6.

      This issue was reported by a customer.

      The customer needs a workaround, or the infomation about encodings that are affected by QTextCodec in the sameway at least.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            hitoshiito Hitoshi Ito
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes