Text Preview line count
Forum rules
You might want to read this if you're looking for priority service
Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).
Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.
How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
You might want to read this if you're looking for priority service
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Text Preview line count
Using Preview to look at a DOS file of just one line (one character, followed by a CR and LF), the line count shows "2" where it normally would be regarded as "1". E.g. Unix's wc reports it as one line.
-
dewcansam
- Posts: 18
- Joined: 18 Oct 2012 05:10
- Location: USA FL
Re: Text Preview line count
Sorry, but I don't agree that this is a bug. It has to do with the way that Linux and Windows handle line endings. And when viewing in "Raw View" in XY on a Windows system. The system will interpret as the cursor is on line 2.
Also You really acknowledged that it was NOT a bug when you said. Noting that "LF" is "Line Feed" and that a Line Feed drops to Line 2. Just as it should.
for example:
In Windows
31 0d 0a <<<< Line 1
[cursor] <<<< Line 2
In Linux
31 0d 0a <<<< Line 1
Open the file up in VI (vi temp.txt) and type it in and in for the status you will get:
2 Lines, 3 characters
Anybody disagree ???
Also You really acknowledged that it was NOT a bug when you said
Code: Select all
one character, followed by a CR and LFfor example:
In Windows
31 0d 0a <<<< Line 1
[cursor] <<<< Line 2
In Linux
31 0d 0a <<<< Line 1
Open the file up in VI (vi temp.txt) and type it in and in for the status you will get:
2 Lines, 3 characters
Anybody disagree ???
XYplorer user since 2008-08
How can you avoid confusion when a dates have at least six different interpretations around the world?
A notation like 01/02/03 could mean 1 Feb 2003 or 2 Jan 2003 or 2 Mar 2001.
Welcome to clarity - ISO 8601
How can you avoid confusion when a dates have at least six different interpretations around the world?
A notation like 01/02/03 could mean 1 Feb 2003 or 2 Jan 2003 or 2 Mar 2001.
Welcome to clarity - ISO 8601
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Re: Text Preview line count
Other Windows utilities also report it as one line.
The reason I'd be looking at the preview is to get a line count rather than doing wc -l from the command line.
That there is one Line Feed means there is one line of actual content.
That viewers of files may show a line beneath that is more of a convenience.
The reason I'd be looking at the preview is to get a line count rather than doing wc -l from the command line.
That there is one Line Feed means there is one line of actual content.
That viewers of files may show a line beneath that is more of a convenience.
-
PeterH
- Posts: 2830
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Text Preview line count
How many lines would you say has
A CR LF CR LF
is it 1, 2 or 3? In other words: do you count empty lines?
I think if you count the 2nd line, you should count the 3rd, too.
Seen another way: a file containing only 1 character has 1 line. (I hope you agree?) If you switch to the next line by adding CRLF you should have 1 line more?
This is the way I interpret this situation.
By the way: my editor (PSPad) shows it just like that! If I'm at the end of the last line it is counted. Now pressing RETURN "opens" a new line, and increments the line count for this new but empty additional last line.
A CR LF CR LF
is it 1, 2 or 3? In other words: do you count empty lines?
I think if you count the 2nd line, you should count the 3rd, too.
Seen another way: a file containing only 1 character has 1 line. (I hope you agree?) If you switch to the next line by adding CRLF you should have 1 line more?
This is the way I interpret this situation.
By the way: my editor (PSPad) shows it just like that! If I'm at the end of the last line it is counted. Now pressing RETURN "opens" a new line, and increments the line count for this new but empty additional last line.
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Re: Text Preview line count
If you have two line feeds, then you have two lines.
-
grindax
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Re: Text Preview line count
Yes.
A file without CRs or LFs is a binary file.
Unix's wc-l reports zero for a file of just one byte, but no CR or LF.
A file without CRs or LFs is a binary file.
Unix's wc-l reports zero for a file of just one byte, but no CR or LF.
-
Marco
- Posts: 2354
- Joined: 27 Jun 2011 15:20
Re: Text Preview line count
Nope. If you have two line feeds, then you have three lines.rd7770 wrote:If you have two line feeds, then you have two lines.
n line feeds => (n+1) lines
A first line exists regardless of how it end. However a CRLF necessarily introduces another line, that might be empty.
At least this is my pov.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Re: Text Preview line count
If there is no line terminator(s) then the file may not be a text file at all.
Just because the content may seem like text to a human looking at it, a bunch of bytes without a CR or LF is at the very least a binary file.
Once there is a line terminator, then the intent of the file is to be a text file, because someone has indicated that it is indeed a text file.
Just because the content may seem like text to a human looking at it, a bunch of bytes without a CR or LF is at the very least a binary file.
Once there is a line terminator, then the intent of the file is to be a text file, because someone has indicated that it is indeed a text file.
-
grindax
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Re: Text Preview line count
The intent of the file is still the same.
If there are no line terminations by the human hitting the Enter key, then it is safer to interpret the file as being binary.
If there were a bunch of characters in a file that are above Ascii 128, with no line terminations, then it likely would be regarded as a binary file.
It is also possible to have CRs and LFs in a binary file that is meant to be a binary file, that might look sort of like a text file, that can confuse software trying to interpert "what" the file "is."
If there are no line terminations by the human hitting the Enter key, then it is safer to interpret the file as being binary.
If there were a bunch of characters in a file that are above Ascii 128, with no line terminations, then it likely would be regarded as a binary file.
It is also possible to have CRs and LFs in a binary file that is meant to be a binary file, that might look sort of like a text file, that can confuse software trying to interpert "what" the file "is."
-
PeterH
- Posts: 2830
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Text Preview line count
...and if you have a binary file containing a CR or LF it is a text filerd7770 wrote:If there is no line terminator(s) then the file may not be a text file at all.
Just because the content may seem like text to a human looking at it, a bunch of bytes without a CR or LF is at the very least a binary file.
Once there is a line terminator, then the intent of the file is to be a text file, because someone has indicated that it is indeed a text file.
I really don't think this helps...
-
rd7770
- Posts: 57
- Joined: 03 Oct 2011 04:36
Re: Text Preview line count
It's not so easy for software to figure out what a file "is".
E.g., suppose the file starts with 0xEF,0xBB,0xBF. That is the usual BOM for UTF-8 files. There are other sequences, in hex, that denote some type of Unicode "text" file.
E.g., suppose the file starts with 0xEF,0xBB,0xBF. That is the usual BOM for UTF-8 files. There are other sequences, in hex, that denote some type of Unicode "text" file.
-
RalphM
- Posts: 2145
- Joined: 27 Jan 2005 23:38
- Location: Cairns, Australia
Re: Text Preview line count
Why don't you just agree to disagree???
Ralph 
(OS: W11 26H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)
(OS: W11 26H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)
-
PeterH
- Posts: 2830
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Text Preview line count
If this was a reply to my text, I don't understand. Do you want to say a text file can be binary, if a BOM exists ???rd7770 wrote:It's not so easy for software to figure out what a file "is".
E.g., suppose the file starts with 0xEF,0xBB,0xBF. That is the usual BOM for UTF-8 files. There are other sequences, in hex, that denote some type of Unicode "text" file.
To verify I made a test on some editors - under windows. Just entered
1
2
3
- without pressing RETURN behind the 3 -
The file is saved as
1 CRLF 2 CRLF 3
Now locating the cursor on (i.e. in front of) the 3 shows "Row 3, Column 1".
Adding a CRLF behind the 3 moves the cursor down 1 line and shows "Row 4, Column 1", i.e. a 4th but empty line is added.
You might want to try the same with an all empty file: it has 1 empty line.
If I'm right you say that XY, saying the same, is wrong?
By the way: a file containing the integer 1.332.219.147 could also be interpreted as Oh(CRLF). This are 2 lines :-)
So: a file "is" not binary or text - it's what you / your program interpret it.
(As said, I've done this with an editor - so it was [interpreted as] a text file.)
(By the way: if its named xxx.txt it probably is meant as a text file.)
And for windows a line doesn't need CRLF as line ending, but CRLF is the move to a new line: and then it's there and counted, even if empty.
We still can talk about something else: if some viewer should show the contents of some file, it could show it interpreted as text, or it could show it in hex. Here it can be of help to inspect the file, and show it appropriate. But as seen with 1.332.219.147 this can be right, or this can be wrong - this isn't a problem of the viewer...
XYplorer Beta Club