linefeed

Why this simple program leads to different carriage return/line feed file when executed in Java and AIX?

雨燕双飞 提交于 2019-12-08 05:28:54
问题 If I run this simple program on Windows 7 and then on AIX (Unix system) and compare the two generated files using a tool such as Winmerge or Compare It, it tells me that the Carriage Return and Line Feed are different but the content identical. Why is that? Isn't supposed to be the same if both use the same encoding "UTF-8" in this case? How can I make both files totally equal? public class WriteFile { public static void main(String[] args) throws IOException { write(); } public static void

Why does .gitattributes not override core.autocrlf configuration on Linux?

浪子不回头ぞ 提交于 2019-12-07 17:20:23
问题 While setting up Git for a project, I've noticed that the line-ending normalization works a bit different on Linux and on Windows. As I understand the Git documentation on this subject, the behavior on Windows is the correct one. Specifically, when a .gitattributes file is present, it should override the core.autocrlf setting. The following table shows the results of some experimentation I've done. The two left-most columns shows the .gitattributes file and the core.autocrlf setting. The

Can't remove empty lines with sed regex

馋奶兔 提交于 2019-12-07 12:14:32
问题 I have a file like this: 2733617 3.00 3 3 2733617 E1b1 8.00 8 16 2733617 E1b1b1b 2.00 2 4 2733617 I1 294.00 296 590 2733617 I2 1.00 1 2 2733617 I2a1 2.00 2 4 sed '/^$/d' does not work for me. Outfile looks just like infile. It should remove empty lines. 回答1: Unfortunately the manual says that using ranges like [!-~] is not safe. However, just printing the lines that containing printable characters using :print: worked for me in the end: sed -n '/[[:print:]]/p' 回答2: Since there appear to be

How can I replace certain carriage return line feed followed by a dash with a <br/>?

删除回忆录丶 提交于 2019-12-07 11:59:16
问题 How can I replace the sequence ASCII 13 ASCII 10 - (CR LF DASH or /r/n-) in the text inside a TD element in a web page using javascript or jQuery? There are similar quesitons about this in stackoverflow and elsewhere, but the solutions listed don't work on this particular scenario. The incoming HTML is generated dynamically by a piece of my customer's legacy software that is not going to be changed, but it references a javascript file that I can change. A shortened version of the page is

Avoid writing carriage return '\r' when writing line feed with Python

自作多情 提交于 2019-12-06 22:24:50
问题 If taken into consideration that carriage return = \r and line feed = \n Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> '{:02x}'.format(ord('\n')) '0a' >>> '{:02x}'.format(ord('\r')) '0d' how to avoid writing carriage return when using open('filename','w').write('text\n') ? In interactive mode you can do this: >>> open('filename','w').write('text\n') 5 >>> for c in open(

How do I remove line feed characters when selecting data from SQL Server?

久未见 提交于 2019-12-06 16:20:08
I insert data that contains a line feed character into the database. Then I retrieve that data. I am using this script to attempt to remove the line feed while selecting the data from SQL: Select Replace(Replace stringname,char(10),'',char(32),'')) from tablename The replace function seems to execute, but it does not remove the line feed correctly. The syntax of your statment looks wrong, maybe you can try with something like this: Select Replace(Replace(@str,CHAR(10),''),CHAR(13),'') The inner replace relaces LF and the outer replace replace CR Shouldn't it be Select Replace(Replace

What is the difference between “\\r” and “\\n”? [duplicate]

淺唱寂寞╮ 提交于 2019-12-06 14:11:16
This question already has answers here : Closed 9 years ago . Possible Duplicate: What is the difference between \r and \n? I understand that it's different for each operating System, for example, "\r\n" may be expected in Windows, "\n" may be expected in Unix snd "\r" may be expected in Macs. What are the differences between these two (or three, if you want to include "\r\n") escape sequences? Why isn't it consistent across all systems? I'm curious about this. Because it just isn't. \r means "carriage return". \n means " new line " line feed Some systems are wise enough to suggest that all

System.lineSeparator() returns nothing

拜拜、爱过 提交于 2019-12-06 09:39:25
What should I see when I use the following? System.out.println("LineSeperator1: "+System.getProperty("line.separator")); System.out.println("LineSeperator2: "+System.lineSeparator()); I get the following back: LineSeperator1: LineSeperator2: Is it empty? invisible? shouldn there be something like \r or \n ? I use windows 7, eclipse and jdk 1.8. As you expect, the line separator contains special characters such as '\r' or '\n' that denote the end of a line. However, although they would be written in Java source code with those backslash escape sequences, they do not appear that way when printed

Why does .gitattributes not override core.autocrlf configuration on Linux?

孤街浪徒 提交于 2019-12-06 02:12:07
While setting up Git for a project, I've noticed that the line-ending normalization works a bit different on Linux and on Windows. As I understand the Git documentation on this subject, the behavior on Windows is the correct one. Specifically, when a .gitattributes file is present, it should override the core.autocrlf setting. The following table shows the results of some experimentation I've done. The two left-most columns shows the .gitattributes file and the core.autocrlf setting. The other columns shows the result of the following git commands: git rm --cached <file> (force next checkout

How can I replace certain carriage return line feed followed by a dash with a <br/>?

好久不见. 提交于 2019-12-06 01:48:23
How can I replace the sequence ASCII 13 ASCII 10 - (CR LF DASH or /r/n-) in the text inside a TD element in a web page using javascript or jQuery? There are similar quesitons about this in stackoverflow and elsewhere, but the solutions listed don't work on this particular scenario. The incoming HTML is generated dynamically by a piece of my customer's legacy software that is not going to be changed, but it references a javascript file that I can change. A shortened version of the page is given below. The actual page contains between zero and twenty rows of data, some of which contain multiple