Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I read in a text file line by line that uses Hex0D as a line terminator?
Forum Updated to NodeBB v4.3 + New Features

How do I read in a text file line by line that uses Hex0D as a line terminator?

Scheduled Pinned Locked Moved General and Desktop
30 Posts 6 Posters 14.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jonathan
    wrote on last edited by
    #21

    As suggested, I've filed bug report QTBUG-18038.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #22

      [quote author="Franzk" date="1299695807"][quote author="peppe" date="1299694316"][quote author="Franzk" date="1299693469"]Actually, the root of the problem is that Qt doesn't accept \r as a valid EOL.[/quote]
      Why should it? No platform supported by Qt uses that control character. [/quote]

      Mac is no longer supported?

      Even if it is true, \r is still a valid line ending and should therefore be supported, even if only by configuration.[/quote]

      Therefore I'm allowed to argue that ASCII 0x07 (BEL) is a valid line ending in my wonderful system, therefore QTextStream should support it? :)

      Come on, stick to reality: if you need custom line endings handle the line splitting yourself. It's easy and always works.

      (BTW: where do those files come from? Mac OS 9?)

      Eventually, you can suggest an API extension to allow for custom line endings in QTextStream, and/or provide the implementation yourself (quite easy) and submit a merge request.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jonathan
        wrote on last edited by
        #23

        My code would have been much tidier if I could have specified the end of line character.

        But to be general, it would have to be a string. Didn't some systems use "x0Ax0D"?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #24

          [quote author="Franzk" date="1299695807"][quote author="peppe" date="1299694316"][quote author="Franzk" date="1299693469"]Actually, the root of the problem is that Qt doesn't accept \r as a valid EOL.[/quote]
          Why should it? No platform supported by Qt uses that control character. [/quote]

          Mac is no longer supported?

          Even if it is true, \r is still a valid line ending and should therefore be supported, even if only by configuration.[/quote]

          Mac OS 9 was never supported during Qt 3 nor Qt 4. Mac OS X uses Unix newlines ('\n').

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on last edited by
            #25

            [quote author="Jonathan" date="1299701652"]My code would have been much tidier if I could have specified the end of line character.

            But to be general, it would have to be a string. Didn't some systems use "x0Ax0D"?
            [/quote]

            Yes, f.i. Windows.

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #26

              [quote author="peppe" date="1299701793"]
              [quote author="Jonathan" date="1299701652"]My code would have been much tidier if I could have specified the end of line character.

              But to be general, it would have to be a string. Didn't some systems use "x0Ax0D"?
              [/quote]

              Yes, f.i. Windows.[/quote]

              That has always been \r\n, not \n\r as stated above.

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Franzk
                wrote on last edited by
                #27

                [quote author="peppe" date="1299701466"]Therefore I'm allowed to argue that ASCII 0x07 (BEL) is a valid line ending in my wonderful system, therefore QTextStream should support it? :)[/quote]That might be taking it a bit far, but if you insist, I'm sure the implementer could take into account that you wish to view BEL as a EOL as well ;).

                Edit: I just added a note to the issue referencing "the unicode standard on newlines":http://www.unicode.org/standard/reports/tr13/tr13-5.html.

                "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • AlicemirrorA Offline
                  AlicemirrorA Offline
                  Alicemirror
                  wrote on last edited by
                  #28

                  Hi Franzk,

                  thank you for your note, but the Newline character I even known is NL, not NEL, or this is another definition that I don't know?

                  Qt full respect the Unicode specifications for this character? Because regardless from this specific case, the differences between the line termination in files became very important on Qt development environment that can work on different desktop platforms (Linux+Mac and Windows) where the sources the same are saved with different line-termination characters: if you try to open a source code created with QT-Linux under Windows (with notepad) it result unreadable, while Qt-Windows does the right interpretation.

                  Enrico Miglino (aka Alicemirror)
                  Balearic Dynamics
                  Islas Baleares, Ibiza (Spain)
                  www.balearicdynamics.com

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Franzk
                    wrote on last edited by
                    #29

                    I usually interpret NL as newline, which is equivalent to \n which is actually LF (LineFeed). NEL is NExtLine. Why there is such a difference I don't know.

                    Notepad has a habit of only accepting \r\n as line termination. Use proper editors ;).

                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dangelog
                      wrote on last edited by
                      #30

                      [quote author="Franzk" date="1299736994"][quote author="peppe" date="1299701793"]
                      [quote author="Jonathan" date="1299701652"]My code would have been much tidier if I could have specified the end of line character.

                      But to be general, it would have to be a string. Didn't some systems use "x0Ax0D"?
                      [/quote]

                      Yes, f.i. Windows.[/quote]

                      That has always been \r\n, not \n\r as stated above.[/quote]

                      Oops, you're right :-) I switched the bytes in my mind.

                      Software Engineer
                      KDAB (UK) Ltd., a KDAB Group company

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved