Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

toddburch

macrumors 6502a
Original poster
Dec 4, 2006
748
0
Katy, Texas
This is quite annoying, and perhaps there is something I can do to lessen the effects of this annoyance, or hopefully, eliminate it.

When writing some ruby scripts in TextEdit, I use a combination of newly written code and cut-and-pasted code from prior ruby scripts. I save the script in plain text and then email the script to my windows machine. In windows, I save the attachment, open it in Notepad, and it all looks quite fine. If I make a change while under Notepad and save it (it has a ".rb" extention), and then reopen in Notepad, all the CRLFs are missing from any lines that were pasted in - only! The cut-and-pasted text I did while in TextEdit is all mashed together. This usually causes the [script to] have syntax errors and I have to manually re-align all the mashed-up lines back into their respective lines.

I've tried emailing the script from Mac as "windows friendly" and also tried saving under Notepad as both ANSI and UTF-8 - makes no difference.

Any ideas?

MacPro 10.4.8.

Thanks, Todd
 
This is a common problem when moving text between Windows and UNIX. I always use Wordpad on Windows rather than Notepad. It doesn't mash the text like Notepad does.
 
OK, I can do this. Thanks for the info. On windows, I mostly use Notepad, but sometimes dip into SCITE if I need line numbers. When saving in SCITE, it applies a certain line-end character that shows up as a tall square back in Notepad in place of the typical CRLF, and the text gets mashed up from that too.

Again, thanks!

Todd
 
Well, I did some more investigation. I wrote a dump program to convert both versions (Unix & Windows) of the text file script to hex.

Unix is using X'0D0D0A' for these CRLF conditions. Windows only needs X'0D0A'. Notepad is obviously stripping out the whole X'0D0D0A'.

I'm going to write a crlf-fixer to run on windows to get around this. Actually, I'll probably make it cross platform if the problem (condition?) is on the mac side too.

Todd
 
You could also get TextWrangler (which IMO is a superior plain text editor to TextEdit) and set the line endings DOS style for those documents you want to share:

Picture 1.jpg

I think that should work...
 
Well, I did some more investigation. I wrote a dump program to convert both versions (Unix & Windows) of the text file script to hex.

Unix is using X'0D0D0A' for these CRLF conditions. Windows only needs X'0D0A'. Notepad is obviously stripping out the whole X'0D0D0A'.

I'm going to write a crlf-fixer to run on windows to get around this. Actually, I'll probably make it cross platform if the problem (condition?) is on the mac side too.

Todd
There are standard utilities like dos2unix, unix2dos and so on installed on most Unixes. Shame about Windows. You can download Windows versions here.

It'd be a shame to re-invent the wheel!
 
Thanks Mitt.. and Robbie.

I've downloaded TextWrangler. Looks like a winner. I like the option for line numbers. Coming from a big IBM mainframe background, line numbers are, as Martha says, a good thing.

I'll probably still write the converter. It's good practice and it will only be about 10 lines of ruby code to do it. I can fit it into my workflow easy enough.

Todd
 
Nope, nix the converter writing. TextWrangler has an option for normalizing line end characters. Done deal!

Now, if I could just cause my END key to actually move the cursor to the end of the line...

Todd
 
Yeah, I figured that out. I've been using control+right arrow. And, control+shift+right arrow to select everything to the end of the line.

Too many keys!
 
Back when I was a Windows user that also had to work on Unix scripts, I used TextPad. It is basically Notepad on steroids. It autodetects the type of line breaks being currently used in the file, so it doesn't break stuff. It does line numbering, context highlighting (for programming/scripting), has a tabbed interface for multiple files, etc. But it's simple to use, so there's never a reason to load Notepad.

It's shareware, but not crippled. I liked it enough, way back when, that I bought a license - no idea where that is anymore.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.