I'm dealing with table values as strings of binary data. When I try to serialize the data using pretty.write the serialization succeeds. However, pretty.read cannot load the data back into a table. It appears that pretty.write is unable to cope with the binary data and ends up truncating its output.
Here are two examples. The first uses pretty with the binary data. You'll notice that the st variable which is the final table with encrypted (binary, string) data run though pretty is missing the ending portion of pretty serialization.
The second example replaces pretty with serpent (https://github.com/pkulchenko/serpent). Serpent is able to serialize and subsequently load the data without issue.
Output of examples:
$ lua pretty-binary-data.lua (https://gist.github.com/4656251)
e == table -> pretty -> encrypt
e == �� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL�
et == { e }
type(et) == table
et == 1
et[1] == �� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL�
st == et -> pretty
st ==
{
[[
�� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL�
pretty.read(st) == should be table with one encrypted string entry
s s[1] or nil e
nil nil not a Lua table
$ lua serpent-binary-data.lua (https://gist.github.com/4656259)
e == table -> pretty -> encrypt
e == �� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL�
et == { e }
type(et) == table
et == 1
et[1] == �� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL�
st == et -> serpent
st ==
do local ={[1]="�� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���\026s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=\026l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL�\000����>|�W�j� �_N��ćw�B\026����E�P�ϼ�H$��ҡ�&ɤ��P�-79PfV�j��\000�FW�.��Q+Xߒ�-j<{-]��d��{���\000��f���9�B��}�nSE����m����3�Ps��L\n�i�n��gy�(����K%LDRL�\n�ۛ�/�F�+ �"����,�r;�v V��B�ʇ�y��įe\��em��z��k���k�\��H(�C���B�s�B��v��i��q�cn��\026#X&hҚ3����Wf�%2'��C���{V����Q[���䐏L7��3Q�>p����$�B�\�q\ǦS>tR�.�x��o�r��,��!�Y�b\000o�\�?L_k���%r4UI�\000��rotT�9���RL;�����d�D%L��Z�pg�P��#����]�U���ⱺS-DzvN�hH6p��VV�8�A�ll*H�V-��c�K��$�^d\n>3ʁ�Q�"};return _;end
f, e = loadstring(st) s=f() == should be table with one encrypted string entry
s s and s[1] or nil e
table: 0x1755d70 �� ��CY.��?Y�輟�|7���M6%�&���BX���kgGy���s�h��ח�la1-�7�e���D>��4�՞��_��@��%P?I��$�A���kc����dc�ܟ=l�3�C!�ȃ�sһ�ӄu�}F/��?��#g�/�h�gL� nil