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. [SOLVED] QTextDocument::toHtml("utf-8") and Arabic on Windows

[SOLVED] QTextDocument::toHtml("utf-8") and Arabic on Windows

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 7.4k Views
  • 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.
  • P Offline
    P Offline
    phedlund
    wrote on 6 Dec 2010, 20:32 last edited by
    #1

    While we are on the topic of rtl languages (http://developer.qt.nokia.com/forums/viewthread/2169) I have a question regarding exporting and viewing such text as html on Windows (XP and/or 7).

    Exporting to html and viewing in a browser "just works" on Mac and Linux, but on Windows I only get question marks. I have tried with fonts such as Arial and Tahoma that the system indicates should be able to display e.g. Arabic.

    Can someone knowledgeable tell me what I am missing?

    Thanks,
    Peter

    1 Reply Last reply
    0
    • I Offline
      I Offline
      infoctopus
      wrote on 6 Dec 2010, 20:48 last edited by
      #2

      do you set a proper codepage for html?
      does it shows correctly if codepage set manually in the browser?
      have you tried misc browsers or just IE?

      Qt rulez

      1 Reply Last reply
      0
      • P Offline
        P Offline
        phedlund
        wrote on 6 Dec 2010, 20:59 last edited by
        #3

        I specify utf-8 as the title indicates. Do you mean something else?

        IE, Firefox, Chrome, makes no difference. Viewing a file generated on Windows with a browser under another OS does also not work so I am pretty sure it has to do with how the file is generated.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 6 Dec 2010, 21:31 last edited by
          #4

          Did you try toHtml("ASCII")? That should generate number based entities in the file for all characters above 127. That's known to work.

          Also, can you display the files generated on the other OS' on the windows box?

          And finallay, do the two files show any differences?

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

          1 Reply Last reply
          0
          • I Offline
            I Offline
            infoctopus
            wrote on 6 Dec 2010, 21:58 last edited by
            #5

            bq. I specify utf-8 as the title indicates. Do you mean something else?bq.

            I mean: what's inside the generated document? Is encoding specified?

            Qt rulez

            1 Reply Last reply
            0
            • P Offline
              P Offline
              phedlund
              wrote on 6 Dec 2010, 22:12 last edited by
              #6

              [links no longer available, use zip below]

              The utf-8 file created on the Mac opens fine on Windows, but of course not vice versa. I cannot see any difference between the files except what is supposed to be the actual text.

              The files are generated from exactly the same code, only compiled on the different platforms.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on 6 Dec 2010, 22:28 last edited by
                #7

                Could you please put all the files in one ZIP. I cannot download that much files from drop box.

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

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  phedlund
                  wrote on 6 Dec 2010, 22:33 last edited by
                  #8

                  http://dl.dropbox.com/u/237357/qt_html.zip

                  They are really small files, but here you go. Thanks for looking at this.

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    infoctopus
                    wrote on 6 Dec 2010, 22:54 last edited by
                    #9

                    Both windows file obviously contain no useful content, a number of 3F/'?' symbols.

                    Another bug found?..

                    Qt rulez

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on 6 Dec 2010, 23:20 last edited by
                      #10

                      The encoding you provide with QTextDocument::toHtml() is only written into the header of the generated HTML. It does not influence the encoding in the returned string (that would be useless anyways, as QString is unicode).

                      How do you write the string to a file? I'd suggest using "QTextStream":http://doc.trolltech.com/latest/qtextstream.html with the right encoding (using setCodec()). QTextStream by default uses a codec suitable for your locale; that might be Windows-1252 and would explain the garbled output on windows.

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

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        phedlund
                        wrote on 7 Dec 2010, 00:27 last edited by
                        #11

                        Aaah, I am relieved it was something simple like that . I already used QTextStream and adding setCodec("utf-8") gave the desired result. Thank you.

                        1 Reply Last reply
                        0

                        6/11

                        6 Dec 2010, 22:12

                        • Login

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