Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...