Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Manchester, United Kingdom
    Posts
    116
    Thanks
    8
    Thanked 17 Times in 16 Posts

    Converting Linux newlines to Windows

    Hi team!

    I'm sure this is really easy, if you know how!

    If I copy text from a web page and then paste it into a Windows program, the Windows program often fails to recognise newlines, showing effectively a single long line of text.

    I believe the main issue is that Windows looks for <cr><lf> at the end of each line, whereas Linux based web servers only provide <lf>. There may also be an issue between ANSI, Unicode, and UTF-8 encoding.

    Over the years I've developed workarounds for most instances. Generally these involve pasting into a program that understands the newlines, then copying and re-pasting into the desired program. For instance, if the text won't paste into Excel I might paste into Notepad first, then copy and paste into Excel. Conversely, if it won't paste into Notepad it sometimes pastes into Word.

    So is there a quick, reliable way to copy text from a web page and paste it into Windows with Windows newlines (and preferably ANSI encoding)?

    Ian.

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,414
    Thanks
    33
    Thanked 195 Times in 175 Posts
    For command-line junkies such as myself, there are mirror programs TODOS.EXE and FROMDOS.EXE
    There is more information (and newer versions!) here.
    You may be able to manipulate it to suit your needs?
    BATcher

    Time prevents everything happening all at once...

  3. The Following User Says Thank You to BATcher For This Useful Post:

    iansavell (2012-02-09)

  4. #3
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Manchester, United Kingdom
    Posts
    116
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Thanks BATcher While I'm also sometimes a command-line sort of person, I'm not sure if tofromdos.exe is quite the thing. Thanks anyway because it solves my other problem of reading my Linux server's Apache log files on the Windows laptop I use to manage it. (currently I read them in Excel!)

    I posted this question just as the latest Windows Secrets landed in my inbox. And Lo! there is an article about GetPlainText, which is a great idea but doesn't correct newlines. It does avoid passing stuff through Notepad though, so if the developer would add a tiny bit of functionality...

    Ian

  5. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts
    If you want a gui program there are third party text editors such as PsPad & Notepad++ that will handle non-Windows files.

    Joe

  6. The Following User Says Thank You to JoeP517 For This Useful Post:

    iansavell (2012-02-10)

  7. #5
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Manchester, United Kingdom
    Posts
    116
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Again, not quite what I was looking for, but I've also been looking for a free syntax-sensitive editor for PHP code for a while and PsPad looks pretty good. Will look at Notepad++ as well.

    Ian

  8. #6
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Jakarta, Indonesia
    Posts
    274
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Ian,

    Quote Originally Posted by iansavell View Post
    So is there a quick, reliable way to copy text from a web page and paste it into Windows with Windows newlines (and preferably ANSI encoding)?
    Which browser do you use? I use Firefox with an extension called Copy Plain Text - EVE. I don't seem to have the problem you experience when I use this. If you also use Firefox, you might wish to give it a try...

    BTW, I have used TextPad for years for (among others) PHP editing. It offers free syntax highlighting for PHP, Java, AutoIt and several other programming languages.

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •