[erlang-questions] Erlang external binary term format

deepblue_other <>
Mon Oct 6 03:29:57 CEST 2008


for example
one day I was looking at the term_to_binary() output of
{binaries,"are",useful}
and it was:
131,104,3,100,0,8,98,105,110,97,114,105,101,115,107,0,3,97,114,101,100,0,6,117,115,101,102,117,108

so with a little experimentation with other tuples I got these rules so far:
131,104       - this means that its a tuple
3                - this means that it has 3 terms
100 and 107 - type code - in this case 100 stands for atoms, and 107 stands
for strings
0                - is the separator between the "type code"(name I gave it
just now ;) ) and the actual ASCII sequence
8 and 3(again) and 6 - these indicate the length of the binary sequence
(number of ASCII characters in this case

so:
binaries - 100(type code),0,8(byte length),98,105,110,97,114,105,101,115
"are"     - 107(type code),0,3(byte length),97,114,101
useful   - 100(type code),0,6(byte length),117,115,101,102,117,108

this just explains a limited set, doesnt go into lists...
I could be wrong, but the rules seem to match up other examples as well

thanks 

deepblue_other wrote:
> 
> term_to_binary() outputs a binary. 
> what is the format of that binary? I would like to create a
> "unpacker/packer" for that format in ActionScript3, and avoid the use of
> XML (which Im using now for Flash-to-Erlang) communication altogether. it
> would be faster, less code, and much more efficient from the bandwidth
> point of view. 
> 
> is there a document someplace that gives the byte layout maybe?
> thank you 
> 

-- 
View this message in context: http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19830881.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list