login about faq

Dear, I do not manage to importer a "bytes" variable into a chilkat.CkAsn() structure. I check with

  • asn = chilkat.CkAsn()
  • bytedata = chilkat.CkByteData()
  • bytedata.append2(payload,len(payload))
  • success = asn.LoadBinary(bytedata)

But but without success, i receive this error

  • return _chilkat.CkByteData_append2(self, data, numBytes)
  • TypeError: in method 'CkByteData_append2', argument 2 of type 'char const *'"

Can you help me, Thanx in advance, Jacky

asked Oct 12 '17 at 12:43

AlphaChrome's gravatar image


This has become a sticky issue since Python 3. When Chilkat was first released, only Python 2.* existed, and it was possible.

I think the best solution for now is to encode the bytes to base64 and use appendEncoded. For example:

import sys
import chilkat
import base64

# Python 3 data = bytes([0x13, 0x00, 0x00, 0x00, 0x08, 0x00])

b64Str = base64.b64encode(data).decode('ascii') print(b64Str)

# Python 2 #data = ''.join(chr(x) for x in [0x41, 0x42, 0x43, 0x44, 0x45, 0x46])

bytedata = chilkat.CkByteData() bytedata.appendEncoded(b64Str,"base64")



answered Oct 12 '17 at 17:11

chilkat's gravatar image

chilkat ♦♦

edited Oct 12 '17 at 17:12

I use the function asn.LoadEncoded(b64Str,"base64") and this OK.

a big thank you, I could never find without your help


answered Oct 13 '17 at 04:15

AlphaChrome's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Oct 12 '17 at 12:43

Seen: 2,728 times

Last updated: Oct 13 '17 at 04:15

powered by OSQA