21 questions
2
votes
1
answer
76
views
What is the proper charset for decoding System#lineSeparator?
Let us say we need to verify the following method.
/**
* Prints {@code hello, world}, to the {@link System#out}, followed by a system dependent line separator.
*
* @param args ...
0
votes
1
answer
57
views
how to insert a newline if yas-selected-text doesn't end with one
setup
given the following text
; indentation guides
(setq highlight-indent-guides-method 'character)
and this snippet
#+BEGIN_SRC ${1:elisp} :tangled
`yas-selected-text`#+END_SRC
$0
problem
If I ...
0
votes
2
answers
83
views
Truncating "wrapping" long string outputs with prefix, appends new line at the bottom of each dump of the hold space
I'm trying to prefix console outputs, while truncating long string outputs to a maximum of 60 characters. (Preventing long lines from bleeding over and breaking the prefix)
How come...
esc=$(printf '\...
0
votes
2
answers
658
views
Does Python still print a trailing newline after printing the contents of a file?
Disclaimer: I know I essentially answer my own question, but please humor me anyway.
I'm working through a Python book I have (Python Crash Course 2nd Edition), and it says, "The only difference ...
0
votes
2
answers
140
views
How to prevent VScode from adding a trailing newline to specific file extensions
You've edited your master.key or credentials.yml.enc file in VScode, and are running into issues when you saved the file because your editor is configured to ensure files have a trailing newline and ...
1
vote
1
answer
50
views
Trailing newline when using scanf() to take string input with whitespace [duplicate]
I am getting problem when using scanf() to take int input, then move to take a whole string that also accept whitespace in it. But somehow the scanf() take place first before the printf() even showed ...
-1
votes
5
answers
5k
views
remove \n from a line in python
I have a txt file that I need to convert into a table. If I have a case like this:
---------------------------------------------
|apple|very good|every day|fruit
|chocolate|not so good|just\n
some ...
0
votes
1
answer
279
views
Why does " %c" in scanf fix the trailing newline character problem?
I am aware that there are numerous posts about why the trailing newline character problem occurs and how to fix it. However, of all the solutions out there, the use scanf(" %c", ch) method ...
0
votes
2
answers
320
views
Linux usb serial line input may lose the trailing new line
I am testing a serial communication protocol based on printable characters only.
The setup has a pc connected to an arduino board by USB. The PC USB serial is operated in canonical mode, with no echo, ...
1
vote
1
answer
481
views
I cannot get Emacs to stop asking me about adding a newline at the end of file
Emacs keeps on asking me
Buffer text.txt does not end in newline. And one? (y or n)
I am confused about why I cannot stop Emacs from making this inquiry. I've set both
require-final-newline
mode-...
0
votes
0
answers
238
views
How do I remove the default newline character from read and write in Fortran?
I am using Fortran 90 and I am trying to get the following without new line
do i=1,size
read*, y(i)
end do
with this, I always get the stdin by using the enter key. Like this
Now, I want this ...
1
vote
1
answer
683
views
How can I make `Tee-Object` not adding a trailing newline in PowerShell?
Tee-Object does not have a -NoNewline switch like many other output-to-file-cmdlets (e. g. Out-File, Set-Content). Under the hood, Tee-Object uses Out-File to write to a file, which adds a trailing ...
0
votes
1
answer
760
views
Serializing class structure to XML seems to add a NewLine character
The code below serializes XML into a string, then writes it to an XML file (yes quite a bit going on with respect to UTF8 and removal of the Namespace):
var bidsXml = string.Empty;
var ...
-2
votes
1
answer
105
views
it works with gets but not with fgets? [closed]
#include <stdio.h>
int main(){
char a[20],b[20];
int i,c=0,m=0;
fgets(a,20,stdin);
fgets(b,20,stdin);
while(a[c]!=0){
c++;
}
for(i=0;i<c;i++)
{
...
2
votes
2
answers
2k
views
Powershell: stdout and stderr to separate files, without new lines
I'm trying to store the stdout and stderr outputs of a command to two separate files. I'm doing this like so:
powershell.exe @_cmd 2>"stderr.txt" >"stdout.txt"
Where $_cmd ...
0
votes
0
answers
226
views
Why does pandas df show tsv's mandatory trailing-newline from pd.read_csv() as NaN?
My programming professor and the internet say I must always append exactly one empty line (=trailing newline) to all my output text files.
Why does
my_df = pd.read_csv('my.tsv', delimiter='\t', ...
0
votes
1
answer
210
views
Remove \n when a line item is being called by subprocess.call (python)
I'm new to scripting / programming and I have a simple script here that takes a .txt file as an input. Within that txt file is a list of encoded data. I am trying to decode them line by line using the ...
2
votes
1
answer
1k
views
Add missing trailing newline to all files in Git repo
Many files in my Git repo are missing a trailing newline:
For consistency, and to remove git-related visual clutter, I would like to automatically add it where it is missing.
13
votes
3
answers
12k
views
Python script should end with new line or not ? Pylint contradicting itself?
I am new to Pylint, and when I run it against my script, I get this output:
C: 50, 0: Trailing newlines (trailing-newlines)
Here, Pylint is saying that it is bad to have a final newline.
I like to ...
1
vote
1
answer
238
views
Lines of text appended with unwanted newlines while using `fgets()` to read a file
This works
$arr = array_merge(array_diff($words, array("the","an"));
Why doesn't this work?
$common consists of 40 words in an array.
$arr = array_merge(array_diff($words, $common));
Is there ...
2517
votes
30
answers
2.7m
views
How to print without a newline or space
Consider these examples using print in Python:
>>> for i in range(4): print('.')
.
.
.
.
>>> print('.', '.', '.', '.')
. . . .
Either a newline or a space is added between each ...