I can display UTF-8 when I use wxPython: ------ import wx app = wx.App() s = 'testing\xf0\x9f\x98\x80' frame = wx.Frame(None, wx.ID_ANY) font = wx.Font("Arial") textbox = wx.TextCtrl(frame, id=wx.ID_ANY) textbox.SetFont(font) textbox.WriteText(s) frame.Show() app.MainLoop() ------ But when I try the same thing with PyQt4.. ------ from PyQt4 import QtGui import sys s = 'testing\xf0\x9f\x98\x80' app = QtGui.QApplication(sys.argv) w = QtGui.QWidget() font = QtGui.QFont("Arial") textbox = QtGui.QLineEdit(w) textbox.setFont(font) textbox.setText(s) w.show() sys.exit(app.exec_()) ------ Instead of "testing😀" ("testing" with a smiley face after it, if you can't see it in this message), I get "testingð" ("testing", then an o with some kind of mark above it).
I tried replacing "s = 'testing\xf0\x9f\x98\x80'" with "s = 'testing\xf0\x9f\x98\x80'.decode('UTF-8')" in case PyQt takes Unicode instead of UTF-8, but in that case I get "testing" and then a little square after it (like the character isn't found in the font). If I copy it and paste it here I get "testing😀" ("testing" with a smiley face after it, like I want), so I guess displaying it in the font is the problem, but I don't know why.. as you can see, both the wxPython and the PyQt examples use "Arial." I've also tried "FixedSys Excelsior 3.01". Python version: CPython 2.7.14 OS: Windows 10 thanks for any help -- https://mail.python.org/mailman/listinfo/python-list