[Seaside] 3.9 and encoding

Philippe Marschall philippe.marschall at gmail.com
Wed Feb 28 09:03:34 UTC 2007


2007/2/28, Norbert Hartl <norbert at hartl.name>:
> On Wed, 2007-02-28 at 00:26 +0100, Philippe Marschall wrote:
> > 2007/2/28, Norbert Hartl <norbert at hartl.name>:
> > > Hi,
> > >
> > > I ran into a encoding problem. I'm using seaside together
> > > with Glorp. For the web server I use WAKomEncoded39.
> > > WAKomEncoded39 converts the output to the browser to utf-8.
> > > But on incoming requests the url escaped characters are
> > > translated to something different. For me it appears to
> > > be latin-1 but I've no glue why it should be that way.
> > > I detected it because my postgresql session has client
> > > encoding utf-8 turned on and I get an error trying to
> > > store strings containing characters like ö.
> >
> > If you run WAKomEncoded39 on Squeak 3.9 you will have strings with
> > (new) Squeak encoding in your image which is basically non-unified
> > unicode. For latin-1 characters this will be indistinguishable from
> > latin-1. If your database is utf-8 you need to encode your strings to
> > utf-8 when writing them to your database and decode your strings from
> > utf-8 when reading from the database (only to convert it back to utf-8
> > when generating html). You can configure the PostgreS database driver
> > to do this automatically for you.
> >
> Oh, this seems quite easy. But I didn't found anything to configure
> in the Postgres driver. Do you have any hint?

PGConnection >> class #buildDefaultFieldConverters
TestPGConnection >> #testFieldConverter

You need to register a field converter for your string types that does
#convertFromEncoding: #utf8

Sorry that does only do the decoding and not the encoding. I guess in
your case Glorp does the encoding. I don't know how you can customize
the Sql generation there but it everything else fails you can change
PGConnection >> #execute (yes, this is a hack)

sql := sqlString.
to
sql := sqlString convertToEncoding: #utf8.

Philippe

P.S.:
PGConnection >> class #buildDefaultFieldConverters
has given us a lot of pain because Squeak doesn't have full block closures

> Norbert
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


More information about the Seaside mailing list