in reply to Advanced snippet management with YAML and Perl

It also happens that YAML is a dirty, evil format to deal with on Win32 (and I suppose Mac as well). It seems to be hung up on the idea that LF is the One True Newline so while it may be convenient for all the people here where \n becomes \x0A after being written to a file, it is ghastly inconvenient for me (where \n is \x0D\x0A) and perhaps similarly inconvenient for Macs where I hear \n is \x0D.

So no more YAML until YAML figures out how to handle newlines sanely. The alternative is that people on standard platforms have to carefully feed all of their YAML data through \r -> ε, which is to say, Yuck!

  • Comment on Re: Advanced snippet management with YAML and Perl

Replies are listed 'Best First'.
Re^2: Advanced snippet management with YAML and Perl
by rje (Deacon) on Jan 04, 2005 at 14:59 UTC
    Perhaps this is a request for a mod to YAML.pm?

    I've not had a problem using YAML on Win32... yet. Thanks for the advance warning.
Re^2: Advanced snippet management with YAML and Perl
by dynamo (Chaplain) on Feb 17, 2005 at 21:39 UTC
    1. I'm a mac user. For the record, it's no trouble whatsoever. Unix and all.

    2.

    package YAML::WIN32NewlineHack; use YAML; use Exporter; our @ISA = qw(Exporter YAML); # only covers scalar string input, but i think this should work sub Load { shift; s/\x0D\x0A/\n/g; Load($_); }

      Thanks for the thought on filtering YAML output. You'd have to do the same thing to DumpFile, LoadFile, and Dump as well to get complete coverage. Then you'd have to teach the loader routines to guess about whether lines use \x0a\x0d endings, \x0d, or \x0a. Thinking further, you'd also have to patch all the YAMLs on *NIX hosts so that when they receive a YAML file which was written on a Win32 machine they can still read it.

      I forgot that Mac had turned into another UNIX recently. I meant that Mac, prior to being a UNIX, used the \x0a line ending. I suppose it uses \x0d now.