Re: line endings in LDRAW files (CRLF vs. LF vs. CR)


Re: line endings in LDRAW files (CRLF vs. LF vs. CR)
#18
As a coder, I thought I'd throw my two cents in.
It is reasonable to expect character- & byte- based parsers and tokenizers to use CRLF as a definitive record break per the long standing specification.
As I've been working on a Java API that will parse and write to the LDraw specs, I used core Stream readers that read a line at a time. I then 'trim' so that the line type is the first character, and there's no trailing white space.
When this runs in a Unix-style system, using just CR as a line-break, trimming also makes the LF's magically go away as they are considered white space.
When I write a file back out I explicitly use the CRLF by emitting the ASCII equivalents of those two characters (0x0D, 0x0A) instead of the various ways insert a line-break using the core API.

Modern applications should be able to parse either way, but in support of long-established standards, they should write the CRLF.
- Greg
"The only stupid question is the one that remains unasked"
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: line endings in LDRAW files (CRLF vs. LF vs. CR) - by Greg Teft - 2012-04-18, 0:24

Forum Jump:


Users browsing this thread: 2 Guest(s)