utf-8 encoding issue

Marc Petitmermet petitmermet at mat.ethz.ch
Fri Sep 19 13:41:19 CEST 2003


The line below looks up the name "öttinger" (with the German umlaut) of 
an author using the mysql console:

 mysql> select author from records where author like '%Öttinger%';

This successfully finds all entries in the records database where 
"öttinger" is the author or the co-author.

In a web form, the user enters "öttinger" and wants to search with this 
search string. My idea is now to convert the search string (which also 
could be e.g. some cyrillic text) into unicode and then to utf-8:

   unicode(search_string).encode('utf-8')

This gives me the utf-8 encoded version of the string but not yet in the 
correct representation. How can I get the correct one (is this the hex 
version? I don't know the correct terminology.)?

In short: how do I e.g. convert a sting containing a "ö" into a string 
containing a "%Ö"?

Regards,
Marc




More information about the Python-list mailing list