• 0

This is going to be complicated to explain... txt file coding(?)


Question

So i have this txt file https://dl.dropbox.com/u/17838/testme.txt

as you can see it's 3 diffrent ip addresses. In Internet explorer in looks like this:

x.x.x.x:x

x.x.x.x:x

x.x.x.x:x

If you'll download and open it in notepad you'll see something like this:

x.x.x.x:xx.x.x.x:xx.x.x.x:x

Now, i can change the above in notepad to:

x.x.x.x:x

x.x.x.x:x

x.x.x.x:x

and save the file and it would look the same on internet explorer.

If i'll create a new txt file and write in it x.x.x.x:xx.x.x.x:xx.x.x.x:x

it will look like this on Internet explorer: x.x.x.x:xx.x.x.x:xx.x.x.x:x

My question is, how Internet explorer (or notepad++ for that matter) knows the first ip ended and that it needs to go down a raw in the original file.

Once i'll figure that out, i want to code something that will convert this:

x.x.x.x:x

x.x.x.x:x

x.x.x.x:x

into this:

x.x.x.x:xx.x.x.x:xx.x.x.x:x

And still keep the rows in it.

6 answers to this question

Recommended Posts

  • 0

As a guess, it looks like you just might be stumbling over line endings. *Nix systems typically go with LF (ASCII 10), Windows goes with CR/LF (ASCII 13, 10). (Makes it fun when you're editing text files on a Unix box via a Windows desktop, and vice versa.) If you're using NotePad++, you'll see "Unix" in the status line, it's detecting the line endings and adjusting itself appropriately. Might help if you visualize it, View->Show Symbol->Show End of Line in NotePad++. Should be a simple matter of your code adding or removing the carriage returns in your text file as needed depending on your needs.

  • 0

As a guess, it looks like you just might be stumbling over line endings. *Nix systems typically go with LF (ASCII 10), Windows goes with CR/LF (ASCII 13, 10). (Makes it fun when you're editing text files on a Unix box via a Windows desktop, and vice versa.) If you're using NotePad++, you'll see "Unix" in the status line, it's detecting the line endings and adjusting itself appropriately. Might help if you visualize it, View->Show Symbol->Show End of Line in NotePad++. Should be a simple matter of your code adding or removing the carriage returns in your text file as needed depending on your needs.

Pretty much this, nice succinct explanation!

  • 0

As a guess, it looks like you just might be stumbling over line endings. *Nix systems typically go with LF (ASCII 10), Windows goes with CR/LF (ASCII 13, 10). (Makes it fun when you're editing text files on a Unix box via a Windows desktop, and vice versa.) If you're using NotePad++, you'll see "Unix" in the status line, it's detecting the line endings and adjusting itself appropriately. Might help if you visualize it, View->Show Symbol->Show End of Line in NotePad++. Should be a simple matter of your code adding or removing the carriage returns in your text file as needed depending on your needs.

Interesting stuff and great info. I was never aware of this. Ok, so i see the LF in notepad++ with UNIX just like you said. In the file i want to convert i see

x.x.x.x:xCR LF so my guess is that i need some how to remove all the CR from the file and i'm done?

Any simple way to do it automatically to a txt file? i don't mind even using a simple batch for it.

For some reason the system we are using at work only accepts one long string in a txt file with LF only.

Edit: dos2unix did the trick. Thanks guys! :)

  • 0

Bunch of different ways you could go about it. Personally not a fan of reinventing wheels, especially for something simple like this. DOS2Unix (or Unix2DOS, depending on which way you're going) is pretty easymode and is available for pretty much everything under the sun. For a Windows version, here's one of many ports. http://sourceforge.n...jects/dos2unix/ Just run it with the text file name as the parameter and done. Of course it's super trivial to write a quick search and replace in whatever language you use if you need something more flexible, but for straight conversion, this is about as easy as it gets.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Ridiculous claim that the labor cost difference of $6000 annually would increase cost per phone by $200. The employees produce 3 phones per month or what?
    • Sparkle 2.20.1 by Razvan Serea Sparkle is a free, open-source Windows optimization tool designed to make your PC faster, cleaner, and more private. With Sparkle, you can easily debloat Windows by removing unnecessary apps and services, disable Microsoft tracking to enhance privacy, and apply performance tweaks to boost speed. Its cleaner removes junk and temporary files, while every change is safe and fully reversible. Sparkle also features a modern, user-friendly interface with automatic updates, making system maintenance simple. Explore over 39 tweaks, from disabling telemetry and hibernation to optimizing network and game settings, all aimed at customizing and enhancing your Windows experience. Sparkle supports Windows 10 and 11. Sparkle 2.20.1 changelog: You can now change the Animation Direction from Up, Left, or Off. Added configurable animation direction (Up, Left, Off) for improved accessibility Added TTL caching to the system info backend Refactored tweak application flow to await NvidiaProfileInspector Improved IPC listener cleanup to correctly remove specific listeners Fixed online status not updating after successful network requests Updated system info tests to support backend caching Removed electron-toolkit utils dependency in favor of internal is.dev helper Fixed unwanted files and folders being included in application bundles Download: Sparkle 2.20.1 | Portable | ~100.0 MB (Open Source) Links: Sparkle Website | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Never used the G7 Pro, but I've never had a good experience with that style of d-pad and fighting games.
    • And I just bought a seat cushion for my mesh chair. The chair feels nice but the first time I sat in it with boxers, I realized I don't like the feel of mesh on my legs. 😂
    • "This Dell 27 inch 4K 120Hz IPS monitor is really cheap after a very long time" ... Lol.
  • Recent Achievements

    • Dedicated
      Asgardi earned a badge
      Dedicated
    • Conversation Starter
      jessse3334 earned a badge
      Conversation Starter
    • Reacting Well
      JuvenileDelinquent earned a badge
      Reacting Well
    • One Month Later
      Excellence2025 earned a badge
      One Month Later
    • Week One Done
      Excellence2025 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      499
    2. 2
      +Edouard
      247
    3. 3
      PsYcHoKiLLa
      153
    4. 4
      Steven P.
      84
    5. 5
      macoman
      64
  • Tell a friend

    Love Neowin? Tell a friend!