newline

How do I create a new line in Javascript?

一笑奈何 提交于 2019-12-17 02:21:02
问题 var i; for(i=10; i>=0; i= i-1){ var s; for(s=0; s<i; s = s+1){ document.write("*"); } //i want this to print a new line /document.write(?); } I am printing a pyramid of stars, I can't get the new line to print. 回答1: Use the \n for a newline character. document.write("\n"); You can also have more than one: document.write("\n\n\n"); // 3 new lines! My oh my! However, if this is rendering to HTML, you will want to use the HTML tag for a newline: document.write("<br>"); The string Hello\n\nTest

git-diff to ignore ^M

允我心安 提交于 2019-12-17 01:19:06
问题 In a project where some of the files contains ^M as newline separators. Diffing these files are apparently impossible, since git-diff sees it as the entire file is just a single line. How does one diff with the previous version? Is there an option like "treat ^M as newline when diffing" ? prompt> git-diff "HEAD^" -- MyFile.as diff --git a/myproject/MyFile.as b/myproject/MyFile.as index be78321..a393ba3 100644 --- a/myproject/MyFile.cpp +++ b/myproject/MyFile.cpp @@ -1 +1 @@ -<U+FEFF>import

Which script would append a new line to a table in “MS Word” 2003?

会有一股神秘感。 提交于 2019-12-14 04:11:20
问题 I have this simple table in MSWord 2003: I want to append one more line to this table: turtle dog rooster maple Which VBScript commands (or set of commands) would I need here to do it automatically? (I am using "Windows XP") 回答1: Here are some notes. Set wd = CreateObject("Word.Application") wd.Visible = True Set doc = wd.Documents.Open ("c:\docs\addtotable.doc") Set r = doc.Tables(1).Rows.Add aa = Split("turtle,dog,rooster,maple", ",") For i = 0 To r.Cells.Count - 1 r.Cells(i + 1).Range.Text

java script newline replacement

微笑、不失礼 提交于 2019-12-14 03:36:37
问题 I finished a JavaScript beginners course and tried to solve the JS challenges in hackthissite.org. in last challenge the obfuscation decryption done correctly but the for loop i executed, output letters below each other instead of beside each other. var puzzle = [0x3c, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x3d, 0x27, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3a, 0x69, 0x66, 0x20, 0x28, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e,

How to have \n convert to newline for emailing PHP? [closed]

白昼怎懂夜的黑 提交于 2019-12-14 03:33:31
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . My code as below $ID = mysqli_real_escape_string($cnx, trim($data->id)); $MSG = mysqli_real_escape_string($cnx, trim($data->message)); $query = "REPLACE INTO mytbl ". "(id, msg, dateentry, status, rate) ". "VALUES ('$ID', '$MSG', NOW(), 'ok', '$RATE')"; $result =mysqli_query($cnx, $query) or die (

How do I stop GCC stripping trailing newline from string literal in obj file?

时光怂恿深爱的人放手 提交于 2019-12-14 02:40:49
问题 Working under Linux, i just met the following issue. (For sure, someone will give me the answer, but up to now,i didn't find any simple and clear answer :) /*compile with gcc -o out.x hello.c*/ #include<stdio.h> int main() { printf("Hello World2\r\n"); printf("Hello World3\r\n "); return 0; } Running the following code under Linux give two strings BUT the ending char are differents: the first output ends with 0x0d while the 2nd ends with 0x0d,0x0a. This is something done by the compiler (GCC)

How to display newline in ssh

巧了我就是萌 提交于 2019-12-14 01:07:11
问题 I'm trying to do the following: #!/bin/sh ssh user@server "echo \"Test \n for newline\"" This displays: test \n for newline How do I get the shell to interpret \n as an actual newline? 回答1: Try using the -e option, e.g., echo -e "Test \n for newline" . If your echo doesn't have a -e option, then I'd use printf . It's widely available and it does not have nearly as many variations in it's implementations. 回答2: For greater portability, use printf instead of echo . #!/bin/sh ssh user@server

\n and \r seem to work everywhere. Why is line.separator more portable?

情到浓时终转凉″ 提交于 2019-12-14 00:47:56
问题 I was just perusing through questions, and I found System.getProperty(line.separator) used in place of \n with the author's comment that the code was "portable". Reading through various forums, I've seen two groups: People who say there's a difference between Linux's and Windows' interpretation of newline characters, and this compensates for that (with no clear evidence). People who say there's no difference by showing code and output examples, which obviously only applies to that code

scanf is reading new line character

依然范特西╮ 提交于 2019-12-13 22:42:21
问题 scanf() always discards white spaces and new line characters. But when I give a character and press enter the new line character is read and stored. I'm unable to read required number of characters because of this. Is there any problem with my code, or some other thing? The same problem goes with gets. Many posts suggested using fgets() rather than using the above both but I need to know why is this happening. 回答1: For %c the man page says (see http://man7.org/linux/man-pages/man3/scanf.3

Get newline stats for a text file in Python

倖福魔咒の 提交于 2019-12-13 19:37:53
问题 I had a nasty CRLF / LF conflict in git file that was probably committed from Windows machine. Is there a cross-platform way (preferably in Python) to detect what type of newlines is dominant through the file? I've got this code (based on idea from https://stackoverflow.com/a/10562258/239247): import sys if not sys.argv[1:]: sys.exit('usage: %s <filename>' % sys.argv[0]) with open(sys.argv[1],"rb") as f: d = f.read() crlf, lfcr = d.count('\r\n'), d.count('\n\r') cr, lf = d.count('\r'), d