[PyQt] Surrogate pair inside HTML paragraph with id is shown incorrectly

Conrado P. L. GouvĂȘa conradoplg at gmail.com
Tue Sep 30 02:41:14 BST 2014


Hi,

This is a very odd bug, but easy to reproduce: (Windows 7, Python
2.7.8 32-bit, PyQt4 4.11.2)

local_app = QApplication([])
buf = u'<html><body><p
id="main">\U0001f604\U0001f604\U0001f604\U0001f604\U0001f604</p></body></html>'
lbl = QTextBrowser()
lbl.setFont(QtGui.QFont("Segoe UI Symbol"))
lbl.setHtml(buf)
lbl.show()
local_app.exec_()


The code above shows two boxes followed by four smilies, when it
should be five smilies. If you remove the "id" attribute of the <p>
tag, the problem vanishes (e.g.:
buf = u'<html><body><p>\U0001f604\U0001f604\U0001f604\U0001f604\U0001f604</p></body></html>'
). It also vanishes if you add e.g. a letter before the unicode smilie.

Any idea what's going on?

Thanks!
Conrado


More information about the PyQt mailing list