Results 1 to 10 of 10

Thread: Does QWebView support Unicode characters > 0xFFFF (for Cuneiform fonts)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2012
    Posts
    7
    Qt products
    Platforms
    MacOS X

    Default Re: Does QWebView support Unicode characters > 0xFFFF (for Cuneiform fonts)

    If I use:
    Qt Code:
    1. HTML = u"<html><body>++\U00012000++</body></html>"
    2. qStr = QString(HTML)
    3. print qStr.toUtf8()
    To copy to clipboard, switch view to plain text mode 
    then the HTML string with the correct glyph in it is printed.

    If I use:
    Qt Code:
    1. #!/usr/bin/env python
    2. # -*- coding: UTF-8 -*-
    3. '''
    4. Created on 7 November 2012
    5.  
    6. @author: nick
    7. '''
    8.  
    9. import sys
    10.  
    11. from PyQt4.QtCore import QString
    12. from PyQt4.QtGui import QApplication, QWidget
    13. from PyQt4.QtWebKit import QWebView
    14.  
    15. # Constants
    16. CUNE_STR = u"\U00012000"
    17. HTML = u"<html><body>++%1++</body></html>"
    18.  
    19. # Main
    20.  
    21. qStr = QString(HTML).arg(QString(CUNE_STR))
    22.  
    23. app = QApplication(sys.argv)
    24.  
    25. widget = QWidget()
    26.  
    27. widget.resize(320, 240)
    28. widget.setWindowTitle("Hello, World!")
    29. widget.show()
    30.  
    31. webView = QWebView(widget);
    32. webView.setHtml(qStr);
    33. webView.show()
    34.  
    35. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 
    then the same problem occurs: a window pops up with: ++<two empty boxes>++.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Does QWebView support Unicode characters > 0xFFFF (for Cuneiform fonts)

    Aarrgghh!! It looks like the Python-esque QString::arg() is mangling your character.

    Perhaps you could use Python methods to put the strings together then do a single conversion into QString.

  3. #3
    Join Date
    Nov 2012
    Posts
    7
    Qt products
    Platforms
    MacOS X

    Default Re: Does QWebView support Unicode characters > 0xFFFF (for Cuneiform fonts)

    I don't think it's a string-combining problem, as even this:
    Qt Code:
    1. #!/usr/bin/env python
    2. # -*- coding: UTF-8 -*-
    3. '''
    4. Created on 7 November 2012
    5.  
    6. @author: nick
    7. '''
    8.  
    9. import sys
    10.  
    11. from PyQt4.QtCore import QString
    12. from PyQt4.QtGui import QApplication, QWidget
    13. from PyQt4.QtWebKit import QWebView
    14.  
    15. # Constants
    16. CUNE_STR = u"\U00012000"
    17. HTML = u"<html><body>++\U00012000++</body></html>"
    18.  
    19. # Main
    20.  
    21. #qStr = QString(HTML).arg(QString(CUNE_STR))
    22.  
    23. app = QApplication(sys.argv)
    24.  
    25. widget = QWidget()
    26.  
    27. widget.resize(320, 240)
    28. widget.setWindowTitle("Hello, World!")
    29. widget.show()
    30.  
    31. webView = QWebView(widget);
    32. webView.setHtml(HTML);
    33. webView.show()
    34.  
    35. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 
    where I make no use of QString, still only produces a box with: "++<two empty boxes>++"

    Considering unicode characters < 0xFFFF, I'm getting some strange behaviour. For example:
    Qt Code:
    1. #!/usr/bin/env python
    2. # -*- coding: UTF-8 -*-
    3. '''
    4. Created on 7 November 2012
    5.  
    6. @author: nick
    7. '''
    8.  
    9. import sys
    10.  
    11. #from PyQt4.QtCore import QString
    12. from PyQt4.QtGui import QApplication, QWidget
    13. from PyQt4.QtWebKit import QWebView
    14.  
    15. # Constants
    16. #CUNE_STR = u"\U00012000"
    17. HTML = u"<html><body>++؀؀\u1250++</body></html>"
    18.  
    19. # Main
    20.  
    21. #qStr = QString(HTML).arg(QString(CUNE_STR))
    22.  
    23. app = QApplication(sys.argv)
    24.  
    25. widget = QWidget()
    26.  
    27. widget.resize(320, 240)
    28. widget.setWindowTitle("Hello, World!")
    29. widget.show()
    30.  
    31. webView = QWebView(widget);
    32. webView.setHtml(HTML);
    33. webView.show()
    34.  
    35. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 
    displays the correct character in the window, but if I change the HTML string to:
    Qt Code:
    1. HTML = u"<html><body>++؀؀\u1200++</body></html>"
    To copy to clipboard, switch view to plain text mode 
    only "++<empty box>++" displays (EDIT: My system seems to have the font to display this glyph because it displays correctly in Mac's Character Viewer).
    Last edited by nickw2066; 8th November 2012 at 20:18.

  4. #4
    Join Date
    Nov 2012
    Posts
    7
    Qt products
    Platforms
    MacOS X

    Default Re: Does QWebView support Unicode characters > 0xFFFF (for Cuneiform fonts)

    **bump**

    Anyone have any idea about the \u1250 vs. \u1200 problem described immediately above?

Similar Threads

  1. Help needed to convert unicode characters
    By hybrid_snyper in forum Newbie
    Replies: 4
    Last Post: 24th August 2012, 15:20
  2. Replies: 6
    Last Post: 30th March 2012, 08:01
  3. QString to unicode characters
    By jsmax in forum Newbie
    Replies: 1
    Last Post: 19th September 2011, 10:41
  4. Unicode/ASCII characters in QTextStream
    By yren in forum Qt Programming
    Replies: 3
    Last Post: 23rd November 2009, 18:25
  5. Insertion of unicode characters into database oracle through pro c
    By hemananda choudhuri in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2007, 10:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.