Strings (was: Re: are Mnesia tables immutable?)

Romain Lenglet <>
Wed Jun 28 12:56:39 CEST 2006

Vlad Dumitrescu wrote:
> hi,
> I don't have a strong opinion about this encoding stuff (more
> that it would be good to have a working solution), but there
> is one thing that
> I'm not comfortable with:
> > bytes 1-2: number of bytes (16 bits)
> (this applies to today's STRING_EXT format too). There are
> cases when one has to handle strings longer than 65536 chars,
> and if sending to external programs, those have to be able to
> handle both STRING_EXT and LIST_EXT, which is a little
> unwieldy.

You're right!

And inversely, if you need to exchange lists of integers that are 
not strings (i.e. the elements are semantically not characters), 
but your lists happen to be flat and all values are between 0 
and 255, then they will be encoded as STRING_EXTs.

I needed to exchange lists of lengths of binaries with a 
linked-in driver, and I was surprised, the first time, to 
receive a STRING_EXT and not a LIST_EXT. :-)

A bad point about erl_interface is that it does not unify both 
representations. ei_decode_string() can decode both 
representations, but not ei_decode_list() (it fails if a 
STRING_EXT is transmitted).
I think that this is the most important point, and what blocks 
you: we should have a cleaner erl_interface that abstracts those 
external representations of strings and lists.
I have thought about how to solve this cleanly, but I have not 
found yet. Once I have found, I will send a patch. ;-)



More information about the erlang-questions mailing list