On 7/4/05, Kuner Martin <[EMAIL PROTECTED]> wrote: > > > Hi list, > > I have the following code to call a LabVIEW VI via the Activex interface. > The string "strDataOut" holds the expected data result of the call . > Now I realized that the string coming back from the ActiveX call contains > Unicode and that is fatal! > The string on the Python side should always be ASCII. > I found no way to convert them back, strDataOut.enocde() raises a exception > when I try to convert to ASCII
Which encoding do you use with strDataOut.encode(...) ? > > Here´s the relevant code. > > intCmdcnt = 0; > strDataOut = r"" > cluError = [False,0,""] > cluSenseKey = [0,0,0] > print "strDataOut = %r" % strDataOut > > arParNames = > ["intChannel","strCDB","strDataIn","intDirection", > "intLength","cluError","cluSenseKey","intCmdcnt","strDataOut"] > > arParVals = [0, strCDB, strBuffer, intDataToHost,intBuffLen, > cluError, cluSenseKey, intCmdcnt, strDataOut] > > retval = self.__refGenericATAPI.Call(arParNames, > arParVals) # call VI > print retval > > The printout: > strDataOut = '' > ((u'intChannel', u'strCDB', u'strDataIn', u'intDirection', u'intLength', > u'cluError', u'cluSenseKey', u'intCmdcnt', u'strDataOut'), (0, > u'\xa8\x08\x00\x10\x00\x00\x00\x00\x00\x10\x00\x00', u'', > 1, 16, (False, 0, u''), (0, 0, 0), 37, > u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00')) > > Here´s another data example: > > String on LabVIEW side : > 00 00 01 BA 44 A5 3F 14 0C AB 01 89 C3 F8 00 00 > String on python side > > u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00' > > Any ideas ? LabVIEW seems to use cp1252 encoding: >>> s = u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00' >>> s.encode('cp1252') '\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\x89\xc3\xf8\x00\x00' Does this string look familiar? :) - kv _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32