[erlang-questions] String/List question

Gleb Peregud gleber.p@REDACTED
Wed Sep 3 12:29:57 CEST 2008


On Wed, Sep 3, 2008 at 12:23 PM, Oliver Mason <o.j.mason@REDACTED> wrote:
> Hi,
>
> I'm currently working on a module to parse/generate YAML files in
> Erlang.  The parsing bit is fine for lists and maps, but with the
> generation bit (which I though ought to be easier) I have a problem,
> and I don't know if there's a solution.
>
> When looking at a list I would usually write each element out
> separately, and recursively in the case of embedded lists.  However,
> as strings are lists, they get written out as lists of numbers.  Which
> for pure serialisation would not be a problem, but if you want to edit
> the file by hand, or exchange it with a non-Erlang system, then it
> becomes a real problem.
>
> Do I need to abandon this, and go for something like {string. "This is
> a string"} to represent strings?  I'd rather not, as it breaks
> compatibility with the standard library modules, but I cannot easily
> think of a way to distinguish between strings and lists of numbers in
> the ASCII letter ranges.
>
> Any ideas?
>
> Thanks,
> Oliver
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>

That's just an idea

You can use binaries for strings. Though you have to decide to use
consistent encoding (like UTF-8) all over the place, and to check if
YAML says anything about it.

-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong



More information about the erlang-questions mailing list