How can I convert Unicode to uppercase to print it?

Alex. S. picture Alex. S. · Apr 7, 2009 · Viewed 32.6k times · Source

I have this:

>>> print 'example'
example
>>> print 'exámple'
exámple
>>> print 'exámple'.upper()
EXáMPLE

What I need to do to print:

EXÁMPLE

(Where the 'a' gets its accute accent, but in uppercase.)

I'm using Python 2.6.

Answer

tylerl picture tylerl · Apr 7, 2009

I think it's as simple as not converting to ASCII first.

 >>> print u'exámple'.upper()
 EXÁMPLE