|
|
Convert end-of-line characters (AppleScript method)
You can also do this conversion in AppleScript. That is very practical if you're going to use files with foreign line endings in Applescripting.
In the following example we have just read the contents of a file and put it into fContents. -- first we ask to put all the lines into a list (fParagraphs). AppleScript doesn't care if it is Unix, Mac or Windows. set fParagraphs to paragraphs of fContents-- now we tell AppleScript that lists will be concatenated using return characters when the list is converted to a string (Mac). This could also be "\n" for newline (UNIX), "\r\n" for character return+new line (Windows) or "\r" for character return (Mac). Don't be alarmed when you compile the script and see that \r and \n has changed into line breaks. The script still know that they are two different characters. set AppleScript's text item delimiters to return-- here we convert the list of paragraphs to strings using the text item delimiters set fContentsNew to fParagraphs as string-- here we reset the text item delimiters to "" which is default. set AppleScript's text item delimiters to ""
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|