TextEdit on Mac -> Notepad on Windows - losing CRLFs

Discussion in 'Mac Basics and Help' started by toddburch, Dec 21, 2006.

  1. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #1
    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
     
  2. Queso macrumors G4

    Joined:
    Mar 4, 2006
    #2
    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.
     
  3. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #3
    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
     
  4. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #4
    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
     
  5. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #5
    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...
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    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!
     
  7. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #7
    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
     
  8. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #8
    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
     
  9. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #9
    You might already know this. Command + right arrow :)
     
  10. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #10
    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!
     
  11. Westside guy macrumors 601

    Westside guy

    Joined:
    Oct 15, 2003
    Location:
    The soggy side of the Pacific NW
    #11
    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.
     

Share This Page