Search code examples
pythonunicodepython-2.xcase-sensitiveuppercase

How can I convert Unicode to uppercase to print it?


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.


Solution

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

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