encoding problems

Diez B. Roggisch deets at nospam.web.de
Wed Aug 29 08:39:23 EDT 2007


Ricardo Aráoz wrote:

> Lawrence D'Oliveiro wrote:
>> In message <46d5215b$0$411$426a74cc at news.free.fr>, tool69 wrote:
>> 
>>> p2.content = """Ce poste possède des accents : é à ê è"""
>> 
>> My guess is this is being encoded as a Latin-1 string, but when you try
>> to output it it goes through the ASCII encoder, which doesn't understand
>> the accents. Try this:
>> 
>> p2.content = u"""Ce poste possède des accents : é à ê è""".encode("utf8")
>> 
> 
> is there a way to sort this string properly (sorted()?)
> I mean first 'a' then 'à' then 'e' etc. (sorted puts accented letters at
> the end). Or should I have to provide a comparison function to sorted?

First of all: please don't hijack threads. Start a new one with your
specific question.

Second: this might be what you are looking for:

http://jtauber.com/blog/2006/01/27/python_unicode_collation_algorithm/

Didn't try it myself though.

Diez



More information about the Python-list mailing list