PythonWin ASP Unicode woes

Steve Holden sholden at
Wed Aug 14 00:25:03 CEST 2002

"Fredrik Lundh" <fredrik at> wrote ...
> Steve Holden wrote:
> > File "C:\Python22\lib\site-packages\win32com\client\", line
> > in
> >  __str__ return str(self.__call__()) UnicodeError: ASCII encoding error:
> > ordinal not in range(128)
> while debugging, try replacing that str() with a repr().
> or perhaps better, replace it with something like:
>     value = self.__call__()
>     try:
>         return str(value)
>     except UnicodeError:
>         print "offending value", repr(value)
>         return repr(value) # fallback

Thanks. It turned out to be \xa0 characters, which I assume came from an
HTML " " via a copy-and-paste operation or some such. For some reason I
could only get a sensible (repr()"able and str()'able) value from the ASP
Request.Form object by using


where I had originally been using


The joys of accessing the ASP object model. It must be great when it isn't
getting in the way ;-) Fortunately this work is being done in the interest
of moving to a CGI environment, so I can hope the heartbreak is purely
temporary. For those cursed^H^H^H^H^H^H who are fortunate enough to use ASP
all the time, a write-up of these potential glitches might be a time-saver.

now-i-know-why-i-use-python-ly y'rs -  steve
Steve Holden                       
Python Web Programming      

More information about the Python-list mailing list