From: Francesc A. <fa...@ca...> - 2005-10-18 11:57:54
|
Hi Stefan, A Dilluns 17 Octubre 2005 21:07, Stefan Kuzminski va escriure: > I am trying to put a pickle string into a VLArray using VLStringAtom. > If the string is larger than a certain amount, I get an error like this > ( the full error is below ) > > ValueError: Problems when converting the object '[snip]' to the > encoding 'utf-8'. The error was: 'ascii' codec can't decode byte 0x86 > in position 4: ordinal not in range(128) Yes, this is due to the fact that Pickle in binary mode is not guaranteeing that the resulting string would be 'ascii' compliant, i.e. that all its elements are chars with ordinal < 128. I suggest you using 'ObjectAtom' so as to serialize objects (it uses cPickle internally). Also, if you want to keep doing the serialization by yourself, then the recommended atom to keep the resulting data is UInt8Atom. =46or example, the next works: vlarray =3D fp.createVLArray( fp.root, 'test', ObjectAtom()) # or also UInt8Atom() vlarray.append( cPickle.dumps( ['aaa' * 130], 2 )) Cheers, =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" |