Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 676
Alex. S. Avatar asked Apr 07 '09 20:04

Alex. S.


People also ask

How do I print Unicode?

We can put the Unicode value with the prefix \u. Thus we can successfully print the Unicode character.

How do I convert Unicode to Ascii?

You CAN'T convert from Unicode to ASCII. Almost every character in Unicode cannot be expressed in ASCII, and those that can be expressed have exactly the same codepoints in ASCII as in UTF-8, which is probably what you have.

Which function converts the Unicode number into a character?

In Python, the built-in functions chr() and ord() are used to convert between Unicode code points and characters. A character can also be represented by writing a hexadecimal Unicode code point with \x , \u , or \U in a string literal.


1 Answers

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

 >>> print u'exámple'.upper()  EXÁMPLE 
like image 52
tylerl Avatar answered Oct 02 '22 09:10

tylerl