newline

Are CRLF lines ok in a Rails project deployed on Linux?

I have a Git repository (originally CVS, then SVN, now Git) containing a Rails project that has been deployed on Linux for a while now. Everything seems to run fine. Now that I've converted to git, I see that many of my files in the repository contain CRLF line endings. I'd love for it to all be consistent (LF), but not at the expense...

How do I append a newline character for all lines except the last one?

I'm iterating through a HashMap (see my earlier question for more detail) and building a string consisting of the data contained in the Map. For each item, I will have a new line, but for the very last item, I don't want the new line. How can I achieve this? I was thinking I could so some kind of check to see if the entry is the last o...

Multiline JavaScript Text

I have a long snippet of HTML I want some javascript variable to equal and for maintainability I want to store it with actual newlines instead of adding \n (or as it is HTML just omitting newline characters). In Python I would do something like: largeString = """Hello This is long!""" And that would work perfectly. However, I haven't ...

Split Java String by New Line

I'm trying to split text in a JTextArea using a regex to split the String by \n However, this does not work and I also tried by \r\n|\r|n and many other combination of regexes. Code: public void insertUpdate(DocumentEvent e) { String split[], docStr = null; Document textAreaDoc = (Document)e.getDocument(); try { doc...

vim Comment Newlines Unexpected Behavior

In using vim, when I start a comment with //, immediately after I type a space, it begins a new comment line. For instance, if I typed the following: //hello world my name is stefan I would get: //hello //world //my //name //is //stefan This behavior has manifested itself in python code as well, where if I begin a line with print,...

python reading lines w/o \n ?

Would this work on all platforms? i know windows does \r\n, and remember hearing mac does \r while linux did \n. I ran this code on windows so it seems fine, but do any of you know if its cross platform? while 1: line = f.readline() if line == "": break line = line[:-1] print "\"" + line + "\"" ...

ASP.NET MVC Html.Encode - New lines

Html.Encode seems to simply call HttpUtility.HtmlEncode to replace a few html specific characters with their escape sequences. However this doesn't provide any consideration for how new lines and multiple spaces will be interpretted (markup whitespace). So I provide a text area for the a user to enter a plain text block of information, ...

Can I change the value of Environment.NewLine?

I'm working with a library that uses Environment.NewLine as it's newline char when writing a file. I need it to write Unix formatted files, and as such would like to change the newline char. Can I change the value of Environment.NewLine? Any other ideas (aside from converting the file post creation)? ...

How to print a newline in an MS-DOS script?

I want to print the output of a program in MS-DOS so I wrote a .bat file that says: cls ruby foo.rb But the output - as it appears on my command prompt - looks like this: c:\workspace>ruby foo.rb foo output c:\workspace> I wanted to insert a newline into the output using MS-DOS because I don't want to pollute my Ruby code with anyt...

Continuing a statement on the next line WITH A COMMENT

If I have a statement in Ruby that I want to continue on the next line, normally I would add a backslash at the end of the line like this: print x \ + y But if I have comments on the line, it doesn't work: print x #show x + y # show y Is there a way around this? (Edit: Squeegy's solution is correct and, actually, I knew you could...

Capturing multiple line output to a bash variable

I've got a script 'myscript' that contains the following: abc def ghi in another script, I call: declare RESULT=$(./myscript) and $RESULT gets the value abc def ghi Is there a way to store the result either with the newlines, or with '\n' character so I can output it with 'echo -e'? ...

java newline character insertion

how can i insert a newline character in a java applet program if i am using "label" instead of sys.out.println?? thanks in advance ...

Does PHP have a function to detect the OS it's running on?

I wouldn't know under what keyword to look for this in the PHP database, so I'm asking here. Reason I want to know is because of how different Operating Systems handle new lines in textdocuments. I'm using a CSV file in windows but each time I think I add a new line, what really happens is the new line gets pasted to the back of the la...

vim enter a new line with tabspaces

Lets say that i have this block of text public function __construct() { parent::__construct(); } and i want to insert a new line above parrent::construct at the same level. Like: public function __construct() { // this is the new line. parent::__construct(); } how can i do this. I try'ed to do CTRL+Enter in command mod...

Losing newlines in div content in IE 7

I'm trying to split the innerText of a div on the newlines in the source for it. This works fine with: $('div').text().split("\r\n|\r|\n") But this fails in IE 7, due to the newlines apparently being stripped out. jQuery 1.3.2 doesn't appear to be at fault since i also tried both: $('div')[0].innerText.split("\r\n|\r|\n") and $('d...

How to add extra newline with 'puts' without sticking newline character into string?

If I say puts "Hello" and decide to add an extra newline I need to do this: puts "Hello\n" Having this character in the string is ugly. Is there any way to do this without polluting my string? ...

[C++] Detect newline byte from filestream

I'm trying to collect information from a textfile which contains names of organisations (without spaces) and floating integers. I want to store this information in an array structure. The problem I'm having so far is collecting the information. Here is a sample of the textfile: CBA 12.3 4.5 7.5 2.9 4.1 TLS ...

escape characters in a CString

How can you put escape characters (like newline character -- \n) to a CString? ...

C# StreamReader.ReadLine() - Need to pick up line terminators

I wrote a C# program to read an Excel .xls/.xlsx file and output to CSV and Unicode text. I wrote a separate program to remove blank records. This is accomplished by reading each line with StreamReader.ReadLine(), and then going character by character through the string and not writing the line to output if it contains all commas (for th...

Post newline/carriage return as hidden field value

I need to post multi-line data via a hidden field. The data will be viewed in a textarea after post. How can I post a newline/carriage return in the html form? I've tried \r\n but that just posts the actual "\r\n" data <input type="hidden" name="multiline_data" value="line one\r\nline two" /> Is there a way to do this? ...