The best way to store arrays as text file?

Richard Gaskin ambassador at fourthworld.com
Thu Jan 11 09:15:49 EST 2007


David Bovill wrote:
> I know what you suggest is faster - but it would not work for complex data
> containing tabs for instance. I don't want this to break when a user tries
> to store something odd in the future, and as i use arrays for all sorts of
> things including htmlText and possible unicode....

By "odd" do you mean binary?

If the user is storing binary info, why not just use the most efficient 
binary format possible in Rev:  a stack file

If the data isn't binary then rather than using ASCII characters like 
tab and return as delimiters you could just as easily choose any 
non-ASCII characters, or a pair of low-ASCIII control characters.

> In general no delimiter is completely safe - safest would be XML is my guess
> - all though I was wandering about JSON as it is simpler. So how about a
> completely general function to store any arbitrary array?

Any delimited file will still requiring some sort of escape.  With 
tab-delimited you need to escape tabs; with XML you need to escape angle 
brackets.

The only way to avoid that modest cost is to use a binary format, such 
as a Rev stack file.

-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________________
  Ambassador at FourthWorld.com       http://www.FourthWorld.com



More information about the use-livecode mailing list