string title() method does not work on Danish characters
jason at jorendorff.com
Wed Feb 27 23:36:50 CET 2002
> I am writing strings from a database, and am using the title() method to
> format the look of the strings.
First: Unicode strings will solve your problem.
Second: I'm on US Windows, so my console won't display the
character Ø properly; IDLE also doesn't really like it, etc.
So below, I'll use \xd8 to refer to Ø.
Okay, here's the example.
>>> s = u'this is a name: MAX M\xd8LLER'
u'This Is A Name: Max M\xf8ller'
Here, Python properly converts \xd8 to \xf8.
To output it, though, you must encode() it properly...
I imagine you probably want Latin-1, so it would be
>>> s2 = s.title()
>>> print s2.encode('latin-1')
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list