Re: Unicode question
Karsten Hilbert <[email protected]> Fri, 25 Jul 2003 00:24:13 +0200
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
Hello Gerhard,
>> I'm having trouble with Unicode. I have set up the database to use UTF-8.
>> I am trying to get some non-ASCII strings in there and I am failing.
>> dBconnection=PgSQL.connect("::ctanWeb:ftpmaint:")
> You need to tell *pyPgSQL*, which client encoding to use. Use the
> parameter client_encoding="utf-8".
Is this also necessary if I use a client encoding of, say,
"latin1" or "iso-8859-15" or some such ? What I mean is: It
makes sense to tell pyPgSQL that my Python code uses "utf-8"
in strings so it knows that it has to deal with u''-strings
rather than ''-strings but why would I need this if I use
latin1 in ''-strings ? In fact, pyPgSQL might be able to
distinguish u'' from ''-strings by a type check (u'' should
return "unicode", shouldn't it ?). So I wonder why I need to
tell *pyPgSQL* what encoding I use ? (I understand why I need to
tell PostgreSQL about that.) I would be thinking that pyPgSQL
just hands it's input to libq. Or does it need to know about
the encoding so it knows how to properly quote/escape input ?
> To also get back Unicode strings for
> text columns, use the parameter unicode_results=1.
That makes sense in that I will get back u'' strings instead
of ''-strings.
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01