Peter Butler a écrit : > >> The solution is: Know where you have byte strings and where you have >> unicode objects. If you have a form, parameters will be byte strings >> encoded with the encoding of the html page. The database stores byte >> strings and has an encoding as well. As a general rule you should use >> unicode objects in your program and know the boundaries where data comes >> in (forms) or gets serialized (database). Encode/decode at those >> boundaries and you are safe. >> > Just for interest, here is how I do this encoding/decoding for CGI > input. There are two encodings defined, the user's preferred encoding > (as sent by the browser in the HTTP_ACCEPT_CHARSET header) and the > application encoding (as used by the database). I use > codecs.EncodedFile (with the preferred and application encodings > reversed) to encode the output before it's sent to the browser. I > hope this helps others in understanding how encoding/decoding works > with web applications, it took me a while to figure it out!
Do you think it's worth bothering about the user browser capability? UTF8 is supported by most browsers. I specify (force) my pages encoding and hope that it will be accepted (and I think it is...) The setdefaultencoding method is the simplest. I don't need portability (it is enough portable for me...) ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss