Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

Python: Certain unicode characters do not display correctly

I am trying to set the label of a GUI-element to display a greek letter with Python.

str(u'u0054'.encode('utf8')) will correctly produce the unicode character 'T', as its unicode number is 0054.

Writing str(u'u03B6'.encode('utf8')) will not display the Greek letter small zeta but this thing instead.

I tried writing str(u'uceb6'.encode('utf8')) as well (ceb6 is the utf-8 encoding of the character I want), but got a similar, strange looking character that certainly wasn't the Greek letter zeta.

According to this site the character is available in common fonts.

Might it be that the GUI-toolkit uses a strange font? I am using the FOX toolkit.

Any help is appreciated.

EDIT: I am specifically trying to create a text label FXLabel(parent, string) where i supply the string str(u'u03B6'.encode('utf8')). And as mentioned, supplying the string with the unicode number of capital t will produce the expected label.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your output encoding is wrong. Make sure your terminal is correctly configured for UTF-8 output.

If I interpret your (rather muddy) image correctly, CE B6 is being displayed as ???? which is consistent with any one of a number of common Western 8-bit encodings.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...