data encoding for Python COM interface

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Max Ischenko

    data encoding for Python COM interface



    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.Unic odeDecodeError: '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.

  • News M Claveau /Hamster-P

    #2
    Re: data encoding for Python COM interface

    Hi !

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

    import locale
    CodingParDefaut = locale.getprefe rredencoding()

    def XYZ(self, argu): # public method
    chaineretour = argu.encode(Cod ingParDefaut))
    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


    Comment

    • Max Ischenko

      #3
      Re: data encoding for Python COM interface


      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.CodePag e property) of the IIS.

      Comment

      Working...