Help wiChanging Text file formats : default vs. MS-DOS Text?

Hello,

Having some trouble with a data text file, that needs to be uploaded to a web site for analysis.

I have worked out a script to use CURL to upload a file (that has been saved using AS “open for access”) to a Web POST form that does some analysis using a cgi. However, it appears that if the file is too large, the cgi does not correctly read the file, and gives an error message.

However, if I send the same file through Word, and then save it as an “MS-DOS Text” format file, the web site reads it just fine.

I have worked out a script to send the file through Word, but, I’m wondering if there is any easier way? Any ideas?

many thanks,
John

Hi John,

I believe that the only diff between dos and mac is the line endings. Dos has carriage return (cr) + line feed (lf). Mac has carriage return (cr). Unix has line feed (lf). So, it seems like different TEXT file formats just differ in the line endings. I’m quite sure that the dos line endings are in that order.

When your reading thing reads this as dos, it sees a mac file (cr) without line feeds. So, I’m not sure, but it might just see one huge paragraph.

You might want to search and replace your text before uploading. Replace cr’s with cr + lf. The basic beginner’s search and replace is something like this:

set the_text to “hello” & return & “Here’s some text.” & “Bye,”
return ReplaceText(the_text, return, return & (ASCII character 10))
---------- subroutines
on ReplaceText(the_text, search_string, replace_string)
set def_tid to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {search_string}
try
set temp_list to (text items of the_text)
set AppleScript’s text item delimiters to {replace_string}
set new_text to temp_list as string
set AppleScript’s text item delimiters to def_tid
on error
set AppleScript’s text item delimiters to def_tid
error “Error in ReplaceText()”
end try
return new_text
end ReplaceText

gl,