PythonWin ASP Unicode woes
Steve Holden
sholden at holdenweb.com
Tue Aug 13 18:25:03 EDT 2002
"Fredrik Lundh" <fredrik at pythonware.com> wrote ...
> Steve Holden wrote:
>
> > File "C:\Python22\lib\site-packages\win32com\client\dynamic.py", line
166,
> > 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
Request.Form["FieldName"].Item
where I had originally been using
Request.Form("FieldName")
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 http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------
More information about the Python-list
mailing list