• 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

    • 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.
    • This Dell 27 inch 4K 120Hz IPS monitor is really cheap after a very long time by Sayan Sen Recently we covered a really good deal on an AMD RX 9070 three-fan model that's available at slightly above its MSRP. If you are looking for a GPU for 1440p gaming that's around the performance of the Nvidia RTX 5070 you should most definitely check it out. Let's say that you are looking for a monitor to pair that up with too. The Samsung 49" G9 curved QD-OLED superultrawide is a good option that can provide an immersive experience. However despite being a very good deal currently (at $855), it may seem unaffordable to you, or you may simply not want to spend as much on a monitor. In that case Dell's S2725QS can be a very good option as it's on sale at the moment for its lowest price in over six months (purchase link under the specs table down below). The big highlight of the Dell S2725QS is its 27-inch IPS panel with a 3840 x 2160 (4K UHD) resolution, offering a high pixel density that can make text appear sharper while also providing plenty of screen space for productivity and media consumption. The display supports a refresh rate of up to 120Hz through both HDMI and DisplayPort, making it suitable not only for everyday desktop use but also for smoother gaming and scrolling. AMD FreeSync Premium support is included as well, helping reduce screen tearing during gaming sessions. The screen has fairly good brightness and color accuracy so you can use it for general work purpose, though photo/video editing is probably not going to be the best match for this. The technical specs of the Dell S2725QS are given in the table below: Specification Value Viewable Screen Size 27 in (68.58 cm) Screen Mode 4K UHD Maximum Resolution 3840 × 2160 Maximum Preset Resolution 3840 × 2160 @ 120 Hz Standard Refresh Rate 120 Hz Panel Technology In-plane Switching (IPS) Backlight Technology LED Edgelight System Pixel Density 163 PPI Response Time 8 ms GTG, 5 ms GTG, 4 ms GTG Horizontal Viewing Angle 178° Vertical Viewing Angle 178° Brightness 350 cd/m² (nits) Native Contrast Ratio 1500:1 Color Support 1.07 Billion Colors Color Gamut 99% sRGB (CIE 1931) Adaptive Sync AMD FreeSync Premium HDCP Support Yes Mount Type Panel Mount VESA Mount 100 × 100 mm Maximum Height Adjustment 13 cm Tilt -5° to 21° Swivel -30° to 30° Pivot ±90° Stand Adjustments Tilt, Swivel, Height, Pivot Glass Hardness 3H Horizontal Frequency 27–270 kHz (DisplayPort 1.4 / HDMI 2.1) Vertical Frequency 48–120 Hz (DisplayPort 1.4 / HDMI 2.1) Video Inputs 2 × HDMI 2.1 (HDCP 1.4 & 2.3), 1 × DisplayPort 1.4 (HDCP 1.4 & 2.3) Operating Temperature 0°C to 40°C Storage Temperature -20°C to 60°C Operating Humidity 10%–80% (Non-condensing) Storage Humidity 5%–95% (Non-condensing) Get it at the link below: Dell S2725QS 27-inch 4K 120Hz IPS monitor: $218.49 (Sold and Shipped by Amazon US) (Was: $280) Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases
  • Recent Achievements

    • 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
    • Week One Done
      flexorcist earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      498
    2. 2
      +Edouard
      243
    3. 3
      PsYcHoKiLLa
      152
    4. 4
      Steven P.
      84
    5. 5
      macoman
      64
  • Tell a friend

    Love Neowin? Tell a friend!