[egenix-users] Zope, MySQL, UTF-8
Jan Stiller
Jan.Stiller at hagen-partner.de
Mon Feb 14 15:41:33 CET 2005
Hi
First of all, my environment:
Windows,
MySQL 4.1,
mxODBC 2.1.0 (downloaded a few day ago),
Zope 2.7.4-0,
python 2.3.4
+ the Zope DA
I need to store Czech or Asian inputs from HTML input fields; is there
any step by step introduction to this 'problem' (or a RTFM-answer with
pointers to TFM)?
My situation:
When I use phpMyAdmin with MySQL everything works fine (even with
Japanese ;o). Inserting the same characters (for testing +ěščřžýáíéäöü
-- '1'-'0' on the czech keyboad + german umlauts), via python and
mxODBC, phpMyAdmin shows:
1, '+ěšÄ?řžýáÃéäöü'
This looks like dumped utf-8 to me.
My settings are:
con = od.Connect(dsn='myodbc',user='root',password='pwd')
con.encoding = 'utf-8'
con.stringformat = od.NATIVE_UNICODE_STRINGFORMAT
#con.stringformat = od.MIXED_STRINGFORMAT
c = con.cursor()
c.execute("update test set textfeld = '%s' where id = 1" %
('+ěščřžýáíéäöü',))
c.execute('select id, textfeld from test order by id limit 2')
additionally I set:
# Set the string encoding used by the Unicode implementation. The
# default is 'ascii', but if you're willing to experiment, you can
# change this.
encoding = "ascii" # Default value set by _PyUnicode_Init()
#js, 11.2.2005
encoding = 'utf8'
in site.py.
I also tried a HTML-Page with a submit to a Zope SQL-Method with the
same effect - garbage...
Since the docu says, that unicode is fully supported, I hope that this
will be possible in Zope too.
If I overlooked something in the fine manuals, please send me a pointer.
tia
Jan
More information about the egenix-users
mailing list