data encoding for Python COM interface

Discussion in 'Python' started by Max Ischenko, Sep 29, 2003.

  1. Max Ischenko

    Max Ischenko Guest

    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.
    Max Ischenko, Sep 29, 2003
    #1
    1. Advertising

  2. 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
    --
    Michel Claveau
    News M Claveau /Hamster-P, Sep 29, 2003
    #2
    1. Advertising

  3. Max Ischenko

    Max Ischenko Guest

    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.
    Max Ischenko, Oct 5, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,797
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Wildepiet
    Replies:
    0
    Views:
    1,849
    Wildepiet
    Jun 14, 2004
  3. Replies:
    1
    Views:
    23,315
    Real Gagnon
    Oct 8, 2004
  4. cyberco
    Replies:
    8
    Views:
    480
    cyberco
    Feb 25, 2006
  5. Replies:
    2
    Views:
    353
Loading...

Share This Page