Text files driving me mad
Sarah
sarahr at genesearch.com.au
Tue Jun 4 17:17:01 EDT 2002
Hi Bill,
I haven't done any of this myself, but I wonder would the CRLF constant
be any use to you?
If you check the Transcript dictionary entry for CR, down the bottom you
will see this:
"The line feed character is the standard end-of-line delimiter on Unix
systems. The end-of-line delimiter for Mac OS systems is a carriage
return, and the end-of-line delimiter for Windows systems is a carriage
return followed by a line feed."
I found it slightly confusing that CR (return) and linefeed are both
ASCII 10, while CRLF is ASCII 13 + ASCII 10. I would have expected CR to
be ASCII 13 and linefeed to be ASCII 10. The dictionary entry makes a
distinction between Unix linefeed and Mac carriage return but in
Transcript linefeed = cr, so I am assuming that Unix uses ASCII 10 and
Mac uses ASCII 13.
Here (in pseudo-code) is what it seems to need:
if system = Windows then
replace CR with CRLF
replace ASCII 13 with CRLF
else if system = Mac then
replace CR with ASCII 13
replace CRLF with ASCII 13
else if system = Unix (& this probably includes Mac OS X) then
replace ASCII 13 with CR
replace CRLF with CR
end if
This is certainly an interesting and important topic, so I will wait to
see how you solve it in the end. It has been very instructive for me to
have a look at this as I had assumed that (as in Hypercard) linefeed was
ASCII 10 and return (or CR) was ASCII 13.
Cheers,
Sarah
On Wednesday, June 5, 2002, at 01:44 AM, Bill Vlahos wrote:
> I'm still having fits over reading in a text file for processing by
> various platforms. There has to be a better way.
>
> If I get URL (http:...text file) each platform brings in a line feed
> only text file correctly. I don't have to do anything on Mac, Win,
> Linux, or Solaris.
>
> If I get URL (file:...text file) I get various results depending on
> which platform as it sees and knows what to do with cr, lf, or crlf. My
> file is currently cr delimited which works fine with Macs and Windows
> but not with Linux. I put in an option to replace cr with lf but it
> doesn't seem to work with Linux. In looking at the Rev docs "return" is
> a synonym for "lf" so perhaps that is my problem. I will try it today
> with replacing ASCII 13 instead of "return". However, all of this seems
> like a hack when the get URL http works all by itself.
>
> Is there a way to have the get URL file command to behave like the get
> URL http command or is this a function of the web server doing the
> right thing?
>
> Thanks,
> Bill Vlahos
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list