how to find the line break in my text file? - line-breaks

I have a text file sent from our customer. The line break in this text file is not CRLF, CR or LF since when I open it using notepad, there is no line, everything is just together. If I open it using word, or VS, I could see the lines. Can anyone tell me how to find out what is the line break in such a file?

Usually LF break works like this.
In Windows I open it using Notepad++ and choose "show hidden symbols"

Related

Attempt to compare character in string to carriage return does not work

I have some code to read a text based file format in that it checks for empty line with:
line == ""
where line is a string that receives a text line obtained through getline.
It worked with my own text based file format, but it did not work with another text based file format (not mine)
I opened the file with gedit and saw nothing. More and less utilities also did not show anything. Then I tried vi and it showed:
^M on all these lines that seemed empty until now (a screenshot of it is here: .
Did some research and it seems that opening the file in text mode, all I needed to do was to compare it to '\n'. So I wrote the line:
if (line[0] == '^M' || line[0] == '\n')
break;
to end a while loop where this "if" is inside, but it did not work. What do I need to do?
As you have already surmised, those ^Ms are vi's way of showing you that there are carriage return characters at the end of each line. The file probably originated on Windows.
As other commentators have mentioned, the way a carriage return character is represented in C / C++ is '\r', and the line endings in that particular file will almost certainly actually be \r\n (CRLF).
So, now you know how it all works you have some code to write. getline will remove the \n but you'll have to strip the \r (if there is one) off the end of the line yourself. Go to it.

Writing text into and retrieving text from the text file using command line auguments

Hello I want to write the output of my C++ Program in a text file using Command Line Argument then afterward retrieve it from the file . can you help me please I cannot get a satisfying code help.
If you are at a unix type command prompt (ie bash or similar), you can generally just redirect your output to a text file using '>'. So if your program is called "MyCommand", just do:
./MyCommand > file.txt
After that, you can use a text editor to open the file, or anything else you'd do with a plain text file.
If you are trying to write out to a file programatically, you need to open up a file handle. There are many ways to do this, one would be to use the standard file handling functions built into the C library. See here for a tutorial:
http://www.tutorialspoint.com/cprogramming/c_file_io.htm

C++ in Windows I can't put the Enter character into a .txt file

I made a program wich use the Huffman Coding to compress and decompress .txt files (ANSI, Unicode, UTF-8, Big Endian Unicode...).
In the decompression I take characters from a binary tree and I put them into a .txt in binary mode:
Ofstream F;
F.open("example.txt", ios::binary);
I have to write into .txt file in binary mode because I need to decompress every type of .txt file (not only ANSI) so my simbols are the single bytes.
On Windows it puts every simbol but doesn't care about the Enter character!
For example, if I have this example.txt file:
Hello
World!
=)
I compress it into example.dat file and I save the Huffman tree into another file (exampletree.dat).
Now to decompress example.dat I take characters from the tree saved in exampletree.dat and I put them into a new .txt file through put() or fwrite(), but on Windows it will be like this:
HelloWorld!=)
On Ubuntu it works perfectly and saves also the Enter character!
It isn't a code error because if I print in the console the decompressed .txt file, it also prints the enter characters! So there is a problem in Windows! Could someone help me?
Did you try opening the file using a wordpad or any other advanced text editor(Notepad++) which identify LF as newline character. The default editor notepad would put it in a single line like you described.
This may not be the solution you are looking for. But the problem looks to be due to having LF as the line break instead of windows default CR/LF.
It looks like it will be the difference in handling EndOfLine on Linux vs. Windows. The EOL can be just "\n" or "\r\n" - i.e. Windows usually puts 0x0d,0x0a at the end of lines.
On Windows there's a difference between:
fopen( "filename", "w" );
fopen( "filename", "tw" );
quote:
In text mode, carriage return–linefeed combinations are translated into single linefeeds on input, and linefeed characters are translated to carriage return–linefeed combinations on output

Find end line in .pdf

I'm developing a plugin for Adobe Acrobat X with C++ that copies all text from opened .pdf in a .txt file. I've tried text runs and text characters from PDEText, it copies all text but it concatenates all lines.
Q: how can I find where end line is in my text?
I made it!
I parse the text letter by letter and I check if they're on the same row verifying top or bottom attribute from ASFixedRect ( I use PDETextGetBBox() to get ASFixedRect ).
Farewell!

Does the Wrap function in ColdFusion insert CR/LFs?

I have the need to do some word wrapping with a few considerations:
Source file is MS WORD
Copy and paste the text into a textarea in a cfform.
Use #wrap(theTextVar,80)# to dump out the text 80 characters
The text is uploaded to a legacy system which needs ansi or ascii chars uploaded.
Everything seems to work okay, I just wanted to confirm see if anyone else has had luck doing this and if they know if a CR / LF is entered after each line in the outputted text (Step 3)?
From the docs on wrap():
Uses the operating-system specific
line break: newline for UNIX, carriage
return and newline on Windows.
So if you are doing this on a Windows box, then the answer is yes.
Tried this?
<cffile action="write" file="i_will_show_the_secret_if_you_open_me_in_text_editor.html" output="#wrap(theTextVar,80)#" />