[Mailman-Developers] "Orignal" MySQL Member Adaptor - 1.71
Fil
fil at rezo.net
Wed Jan 7 15:43:51 CET 2009
> It should according to the docs I found, provided I've applied them
> correctly, fix the non-ASCII character encoding problems (I've relied on
> the assertions about list members to cover that angle, and just checked
> encoding on the 'user supplied' parameters to various function calls).
Hi Kev,
I finally got the time to look at your character encoding problem and
patch, and I was not able to make it work. I still getting the dreaded
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 1: ordinal not in range(128)
On my version of MysqlMemberships.py there is a centralized function
which does the escaping and is used on every sql request:
def escape(self, value):
# transforms accents into html entities (é)
# TODO: find out which language is current (here: uses iso-8859-1)
value = Utils.uncanonstr(value)
# addslashes before " and '
return MySQLdb.escape_string(value)
I tried to add your unicode logic at this point, but to no avail. And
BTW I also need the thing to be functional both with utf8 and
iso-8859-1.
For people who'd like to join in the conversation, the logic I'm
refferring to is the following:
# safe unicode strings encoded for mysql
# http://effbot.org/pyfaq/what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean.htm
try:
unicode(value, "ascii")
except UnicodeError:
value = unicode(value, "utf-8")
else:
# value was valid ASCII data
pass
-- Fil
More information about the Mailman-Developers
mailing list