2

I am working on a little euchre project for those of you who are familiar with that. I need suit symbols to identify the cards in my game. Unicode seems to be the best way of doing that.

I am using Eclipse for IDE developers coupled with a pydev module. It's running Python 3.0.

It should just be as simple as:

club = u"\u2663".encode('utf-8')
print(club)

My output is literally:

>>> b'\xe2\x99\xa3'

What am I missing?

1
  • 1
    Python 3.0 doesn't support the u"" syntax (which you shouldn't be using in the first place), so I doubt it's the exact version you have. Most likely it's 3.3. Commented Jun 12, 2013 at 16:49

2 Answers 2

7

Don't encode; the sys.stdout file stream is opened with your terminal encoding and encodes unicode for you:

club = u"\u2663"
print(club)

You don't need to use u''; python 3 strings are unicode values by default.

Demo:

>>> club = "\u2663"
>>> print(club)
♣
Sign up to request clarification or add additional context in comments.

Comments

5

That you shouldn't need to encode.

3>> print('\u2663')
♣

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.