Text File’s End-Of-Paragraph on Mac vs Windows

Text File’s End-Of-Paragraph on Mac vs Windows

 

How many times have you opened a text file only to froth over the formatting? Either it’s a dense chunk of text with no returns, as in lacking a new line, also related to as full stop, end-of-line, end-of-paragraph or something else. Or it’s waaay to many empty lines between the sentences or paragraphs.

You reach for the phone/mailer/fax and fire off a complaint. Rightly so, but the other end feel wrongly accused, and can’t understand what the deal is since it looks pretty alright in her end. She gets angry. After a while it’s a Windows user vs Mac user battle. Or struggle.

The ordered/bought material has flaws according to the recipient/buyer. This is correct.

The creator thinks the one that’s complaining is a, yeah, idiot. This is correct.

Or, rather it’s incorrect, as in; faulty assumptions at each end.

 

What’s happening here?

The problem is prehistoric. It stems from a time we consider extinct. We don’t use those 8-bit computers anymore. And today there’s a lot more to that old 7-bit ASCII table that dawned when programs and data was stored on punch-cards.

Let’s not write a book about ancient times now. We want a solution. I just want to lay the floor so we can reach the other end safely. There is a solution but keep reading.

We have a text file. Can we agree on that? It is like any other file on our hard drive. It contains binary data which in this case is interpreted as text by the application that opens it, be it Word, Notepad, Wordpad, Textedit or Pages. What ever. The application is designed to interpret the binary data and convert it to characters for us to read. I know this is low level but it’s interesting, simple, and good to know.

While the data has bytes of values that can convert to characters for us to read, it is also data that doesn’t convert to readable form. Those are the line feed (LF) and carriage return (CR) characters. They are used to create the basic formatting of the text. Just like the mechanical typewriters which we all know have a carriage (that holds the paper) which we had to manually return. While returning the carriage to the right we also pushed the lever to get to the next line. We inserted a LF before we returned the carriage, physically. This was also referred to as the end-of-line character or even new line, NL–since we didn’t knew about automatic line-wrapping back then. In Windows we still see these characters coupled today. At the end of a paragraph, we hit the return key and the input system signals to the application what key we pushed. The application inserts two bytes according to system rules, with the values that converts to LF and CR.

Using any other system, the behavior is different. On a Mac, the same signal is also sent to the application but here, the application inserts a CR. One CR only.

Maybe Apple didn’t think much of our ancient mechanical typewriter or they simply wanted to have their own way to contradict Microsoft’s take on the matter. I don’t know, and frankly, I don’t care. Those of you that want to go to war about it, please, be my guest but take it to the desert. I don’t want to hear about it. The thing is that there are more differences out there. UNIX, and all its lovely derivates, uses a single LF instead of a single CR. The philosophy was that the LF moved us down one line and as we type from left to right, we should automatically be at the leftmost column. These differing behaviors were coded into the applications.

 

More History!

Anyway, the main reason to why this type of single-byte end-of-line handling was adopted, was to save space. Back then, storage space was expensive, tight, and hard drives were slow. For the laugh of it, I remember I bought a 20 MB Add-On hard drive to my Amiga 500 in 1989. I had to pay about $900 for that A590. I had to partition it since it was so huge. LOL

Network speed was sluggish and everything had to be madly optimized and be at its smallest possible. Acronyms is another kind of space reducing method. A huge text file would not take up as much space when the end-of-line was one byte instead of two. Right, go ahed! Laugh!

We can all laugh at that today but did you know that one single byte can take up as much space as 2048 bytes on your hard drive? No, you say. Can’t be. Yes, can. A hard drive is divided into blocks–among other dividing ways to make up a file system–which are the smallest part onto which you can save data. If your file, spread over many many blocks, has one byte left to store when the file system filled the block before the last block, that single byte has to take up a whole block. One block on the hard drive usually holds a number of 512, 1024 or 2048 bytes. That’s it. One byte would own the whole block. 8 bits. It will take up at the least 512 bytes. It’s like having a number of boxes to store your stuff in. You want to store a wooden 6 by 4 inch beam? Only have size 20 by 4 by 6 inch boxes to use? You have to cut the beam up in 20 inch pieces. Just like your text file. At the end you may have a 1/4 inch piece left and have to use a whole box for that small piece. You’re not allowed to store other things together with the beam-piece in that last box. A waste of 19 and 3/4 inch storage space. There’s the history. Floor laid. Hope you got some usefulness out of it. I’ll write more on filesystems another time if anyone care to know.

 

What About The Content Then?

Now that the floor’s done, let’s walk it and have a nice cup of coffee while we look at the differences.

Here’s a mac and windows text file, saved as text and later opened with a hex editor (heaxdecimal editor):

 

 

The arrows in the lower image points out the non-printable bytes as 0D and 0A. These are the LF and CR characters that Windows wants. The Mac file don’t have the LF character and that’s why Mac files seem lacking a hard-break, end-of-paragraph or new-lines on a Windows system.

Now we know how this is a problem between different systems. The Mac file only has the 0A while the Windows file produce both 0D and 0A for each tap at the return key. These guys are non-printable characters so they’re shown as periods in the hex editor’s right pane in the images.

The wonderful solution to this problem emerges from the adaptive and creative minds of the Mac community. (Slight but friendly pun there – Couldn’t resist, sorry 😉

Bare Bones Software have been with us for aeons. They developed BBEdit back when the Mac looked like a fish tank. The Mac was the system of choice among people that were engaged in layout and typesetting. The Mac was the ruler of typeface, graphics, audio, creativity, publishing and the beauty of words, created and delivered by the Steves. Well, it still is. Ou gof iw… ouch, who put a sock in my mouth?

Now, BBEdit is a commercial product. It’s a monster tool but still only $50. Hold it! Hold it! You don’t have to buy anything. See, BBEdit has a little brother called TextWrangler. He’s swift, strong, smart, and free. Here’s what he allow me to choose when I Save As…

 

 

Here you see the LF and CR in the “Line break” drop down selection. Wonderful simplicity at the fingertips. TextWrangler adds the LF guy before every CR it finds when it saves the file. Voilá, we have a 100% compatible Windows (DOS) text file. Notepad addicts can happily chug along with their tool of choice. Warms my heart. I love it when people don’t have to change things that work for them.

 

And the All Famous Bottom Line

Here you find TextWrangler from Bare Bones.

Here’s a quick note if you want to know to what else you can put TextWrangler through.

The best of all is that it’s FREE! Feel tha taste, Maccer! It comes on a Disk Image for your convenience. Just double click when it’s on your hard drive. It mounts and opens. Drag the App Icon to the Application Alias and let go. While you’re there, double-click the Application Alias to open your Application Folder. Hit ‘T’ on your keyboard to fast-jump to the apps that starts with ‘T’ and drag TextWrangler to your Dock. Then start it. Register for updates. Oh yes, the updates are also as free as can be. Turn up the volume and fire off your creativity. TextWrangler downloads the PDF Manual when you start it. In this great PDF you can learn a billion things about TextWrangler and text editing. Read it. You can’t possibly imagine how great this Little Brother is.

A smart way to simplify life is to menu-click TextWrangler in your Dock and select Open on Startup. Then it’s there, always. Blistering fast. Copy and Paste your work from Open Word, Pages or MS Word for Mac into TextWrangler and save as Windows, Mac or UNIX text file in separate files.

You can also open Info on any text file and select TextWrangler as the Open With app. Then click Change all… to have all text files open with TextWrangler through a double click. This way you only have to choose whether it’s a Windows text file you’re saving or not. I still prefer Apple’s Textedit as I can convert between TXT, RTF and RTFD in a whim. It just happens when I drag a file into the window. Image, video, sound, text clip, Word file, Web pages, links, whatever. Just like Mac, as usual.

I don’t know if I’m going to convert my PLR text files, save them in different folders, and pack them up together in a zip file OR if I should make them available as separate items in my store. I think I’ll separate them. Macers will have a dmg-file and windowers will have to fiddle with messy zippers. PLR packs comes with no cover images so I could use the mac/win logos for that. This is great, I suddenly DOUBLED my content in the store and made it look nicer. Yay. 😉

This has come out nice. A HUGE thank you from me go out to, Kate, Matt and all of you who contributed to the heads up on this subject. This is a great solution we all can take to our hearts. Oh, all Maccers i.e. If you’re on Windows and run into this problem from a Mac user, send him or her over here to read and shape up. If a Maccer buys PLR from a creator on Windows, this is of no great concern.

“What? Who’s there?”
“Ahh.. It’s me, your obnoxious memory. I have something to say.”
“What? We’re done here now.”
“Oh… but this is about text also.”
“About text? What? Anything on line feed or carriage return?”
“Erh.. no but I know there are some more things I would… like to talk about.”
“Well, that’s good. Go sit over there and write it down. I’ll take a look at it when you’re done. OK?”
“Well, yeah. OK. Over there?”
“Yup. Catch you later…”
Share the joy

2 thoughts on “Text File’s End-Of-Paragraph on Mac vs Windows

  1. Yes,this is the Matt from the article. I am run windows,and Agneta runs Mac,this is where the story here starts from.
    I received some articles from her, which i needed for a client, and when i received them,they where one long paragraph.
    I was thinking,WHAAAAAAAAAT? Then i told her i was on a windows platform,and how most of us receive our articles.
    So,here is the result of our conversations back and forth, quite a few to say the least.
    Now we are friends, have some common interests, and i am here once again.
    Oh,by the way, she did not tell me to post this,and her articles are top notch.
    I would not have used them for a client if they were not.
    Have fun Agneta, and best of luck always.

    • Hi Matt!

      LOL, yes, this came out to be a nice resource. I’ve just spent a couple of hours playing around with TextWrangler. It’s a mind-boggling app. I’ve converted all the text files so they’re Windows files in all packs now. I’ve zipped them and had the Mac files in separate Disk Image files. I’m about to upload them now.

      Thanks Matt! Fly low and slow so you can get out quick, and take a cab if things get dirty up there. 😉

Comments are closed.