[Python-Dev] Re: [Patches] Patch for xmlrpc encoding

Fredrik Lundh fredrik@pythonware.com
Tue, 10 Dec 2002 09:40:26 +0100


Ragnar Kj=F8rstad wrote:

> > There isn't a reason to assume that strings use any other encoding,
> > either.=20
>=20
> Isn't that what sys.{get,set}defaultencoding is for?

Tthe default encoding stuff was added for experimental purposes only; in =
the
early days, there was some disagreement on whether the default encoding
should be UTF-8, ISO-Latin-1 (8-bit subset of unicode), or ASCII (7-bit =
sub-
set of unicode).  We finally settled on ASCII, for a couple of reasons.

Robust application code should assume that the default encoding will =
*always*
be ASCII, and use Unicode strings and ASCII-only strings for text.

> So perhaps it would be better to change the postgresql-modules to =
return
> unicode-objects instead of strings?

That's the correct solution, yes.

Checking for chars>=3D128 and returning Unicode only if the string =
contains
non-ASCII characters is also a valid approach.

</F>