A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/099625.html below:

Another COM question

Another COM question Another COM questionAlex Martelli aleaxit at yahoo.com
Sun Apr 8 03:11:24 EDT 2001
"Volucris" <volucris at hotmail.com> wrote in message
news:3ad001dd$0$837$6e49188b at news.goldengate.net...
    [snip]
> I get the following error when I call my Python COM object though VB:
>
> Unexpected Python Error: exceptions.UnicodeError: ASCII encoding error:
> ordinal not in range(128)
    [snip]
> Does this have something to do with COM dealing in Unicode? Or what?

Exactly: your Python code is giving a Unicode object to a function expecting
a string, and the implicit Unicode->string conversion uses ASCII encoding
(so it can only handle characters whose ordinals are below 128).  You may
use an explicit call to the x.encode() method of a Unicode object x to get
as the result the encoded string; you may pass as an argument the name
of your preferred encoding ('iso-8859-1' is quite popular in Western Europe,
for example).  Haven't examined your code in detail, but I think you need
to do a
    data = data.encode('iso-8859-1')
at the start of your method.


Alex




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4