From: Jeremy Bopp Date: 2010-12-14T04:48:52+09:00 Subject: Re: Substituting New Line Character On 12/13/2010 12:41 PM, A. Mcbomb wrote: > I have a bunch of text that I need to inject a newline character. In my > code, I found a way to put a "\r" where I want the carriage return but > it doesn't work. I also tried "\n" and that doesn't do it either. What > character should I inject to make this text go to the next line where I > currently have the "\r" ? There are multiple standards for the end of line character sequence in text files depending on the platform on which you're running. Windows uses \r\n, Unix uses \n, and I Macs prior to OSX used \r. Your content looks like HTML markup though, so depending on where you want your line breaks in the file and whether you're rending it as raw text or HTML, you may actually need to insert
tags. Assuming you will render the file a raw text, the first thing you have to do is identify what line ending sequence you need in order for your text to render correct using the tools you support for the task. Most common text editors on Windows will only handle \r\n correctly, but some such as TextPad and Write will do the right thing. The platform on which you run can serve as a guideline for a good first guess if you're unsure. Then process your text to insert the line ending sequence of your choosing. If things still don't render correctly, view your processed text in something like a hex editor in order to ensure that you actually processed it correctly. -Jeremy