7 Jan
2009
7 Jan
'09
5:29 p.m.
I was able to go a bit further with the script below. Unfortunately when that utf-8-encoded mysql-escaped string goes back up into MySQLdb I get hit by another encoding error inside MySQLdb. So my best for the moment is to stay with my current implementation which escapes all strings to html decimal entities.
#!/usr/bin/python
import os, sys import MySQLdb from types import StringType,UnicodeType
a='\'And"ré'
try: b=unicode(a,'utf-8') except: b=unicode(a,'latin-1')
print b.encode('latin-1') print b.encode('utf-8')
print MySQLdb.escape_string(b.encode('utf-8'))
-- Fil