[XML-SIG] cStringIO

Fred L. Drake, Jr. fdrake@acm.org
Fri, 25 May 2001 11:55:36 -0400 (EDT)

Rich Salz writes:
 > Sorry, I don't understand.  What's a non-ASCII unicode string?
 > Something with the high-bit on?  If so, then doesn't httplib.py
 > have a problem using cStringIO ?

  Yes; any Unicode string that contains non-ASCII characters can't be
converted to an 8-bit string correctly since the ASCII encoding is
used by default (and there's no way to tell cStringIO to use a
different encoding).
  Why would httplib have a problem with cStringIO?  Pulling data over
a socket always yields 8-bit strings, which work just fine with
cStringIO regardless of the high bit.  The problems with the cStringIO
and Unicode are based entirely on the implicit conversion of the
Unicode to ASCII, not the 8th bit per se.


Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Digital Creations