data encoding for Python COM interface

M

Max Ischenko

I've wrote a COM Server (in python) to be used from .ASP pages (in VB).
All work fine except data encoding. I need to pass Latin1 characters
(with Umlauts) through the COM interface.

If i simply pass my unicode data as is through the COM interface I got
no errors but Umlauts simply disappears on the web pages (ae becomes a).

If I do encode my data in 'iso8859-1' in COM Server
I got this error while evaluating .ASP page:
Python COM Server Internal Error (0x80004005)
Unexpected Python Error: exceptions.UnicodeDecodeError: 'ascii' codec
can't decode byte 0xe4 in position 16: ordinal not in range(128)
somepage.asp, line 33.
Note, however that test python COM client able to read and save data in
utf-8 encoding and it is displayed correctly (via NotePad).

Error ... 'ascii' codec ... makes me suspect that I could (or should)
somehow specify the correct codec for my COM interfaces.

tia.
 
N

News M Claveau /Hamster-P

Hi !

In other environment (windows + Paradox/objectPal +COM-python-script), i do
:

import locale
CodingParDefaut = locale.getpreferredencoding()

def XYZ(self, argu): # public method
chaineretour = argu.encode(CodingParDefaut))
return chaineretour

This work (encode in entry to COM-python nothing at return).
Perhaps can you find in an idea ?


* sorry for my bad english *


@-salutations
 
M

Max Ischenko

Replaying to myself as someone could find this useful.

COM server should return proper Unicode string. To decode it as Latin-1
in ASP use CodePage directive (or Session.CodePage property) of the IIS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top