Python garbled characters, python encoding, python Chinese encoding conversion

Python encoding conversion
This 2.6 is used to transition to 3k, I still look forward to py3k, wxwidget3 is also under development, the main changes of the two are invariably focused on the unicode problem, now using py2.5+wxpy2.8 to make software, the most inconvenient thing is the encoding problem, using iewin's LoadString to output Chinese is not easy to handle, this problem has been asked before in this list, but unfortunately there is no
solution
.
Looking forward to the future py3k+wxpy3 can solve the encoding problem once and for all.

My solution, LoadString supports converting Chinese
characters into html entity characters.
echo mb_convert_encoding ("Replay", "HTML-ENTITIES", "gb2312");

Encoding conversion
s = "Chinese"
s1 = u"Chinese"

unicode -> gbk
s1.encode(“gbk”)
unicode -> utf-8
s1.encode(“UTF-8”)
gbk ->unicode
unicode(s, “gbk”)
or
s.decode(“gbk”)

Guess you like

Origin blog.csdn.net/wbryze/article/details/131579476