Windows PCs use carriage return-line feed to terminate paragraphs. (ASCII character 13 & ASCII character 10) so:
set pc to (ASCII character 13) & (ASCII character 10)
set myPara to "The quick brown fox" & return & "The moon is blue" & return
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set p to text items of myPara
set AppleScript's text item delimiters to pc
set pcT to p as string
set AppleScript's text item delimiters to tid
pcT
NOTE: Just to make it interesting, UNIX uses \n (new line, or line feed - ascii 10) while Macs use \r (return or carriage return -ascii 13), so depending on how your text was produced, you might be replacing 10 by itself with 13 followed by 10.
Thanks Adam, I’ll try this… but I was hoping it would be as easy as “save as pc text”!
The original file was UNIX, but oddly enough it opens fine in both Mac and PC… the line breaks don’t get messed up until I use “write” to create a new text file with the data I need.
In fact, to go a bit further, paragraphs are correctly interpreted for any of them:
set txtN to "first line" & (ASCII character 10) & "second line" & (ASCII character 10) & "third line"
set txtR to "first line" & (ASCII character 13) & "second line" & (ASCII character 13) & "third line"
set txtP to "first line" & ((ASCII character 13) & (ASCII character 10)) & "second line" & ((ASCII character 13) & (ASCII character 10)) & "third line"
set pN to paragraphs of txtN
set PR to paragraphs of txtR
set pP to paragraphs of txtP
repeat with aP in {pN, PR, pP}
set text item delimiters to (ASCII character 13) & (ASCII character 10)
set contents of aP to contents of aP as string
set text item delimiters to ""
end repeat
The other thing that can be screwing you up, however, is that if Darwin created the text, it may be Unicode text, and the PC doesn’t know what to do with that.
Well, it is unicode text, because that’s what I thought it needed to be. Would saving as text instead of unicode text fix the problem?
Here’s a snippet of the script:
set writeme to (items 2 thru 5 of mylist) as Unicode text
my write_to_file(writeme, this_file, true)
on write_to_file(this_data, target_file, append_data)
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
end write_to_file