Kiwa
Kiwa

Reputation: 215

How to determine the size of a file from the strings

I have a test file called text.txt. Its contents:

as
bq

df

But the file size of text.txt is 12 bytes. Why is it 12 bytes? The first line has 3 bytes as\n. The second line has 3 bytes bq\n. The third line is 1 byte \n. The fourth line is 3 bytes dfEOF.

3 + 3 + 1 + 3 = 10 bytes

But when I check the size of the file, it says 12 bytes. If I just have a single character in my txt. It says 1 byte. So I am confused as to how I get 12 bytes

A GIF of my one notepad++ pressing the right arrow key. Showing you there is no spaces whitespace: https://gyazo.com/82717bd0e339188adae3d72dc243ba37

My hex: 61 73 0d 0a 62 71 0d 0a 0d 0a 64 66

Upvotes: 0

Views: 1746

Answers (1)

Andrew Henle
Andrew Henle

Reputation: 1

Given the contents are

My hex: 61 73 0d 0a 62 71 0d 0a 0d 0a 64 66

Your 12 bytes are

61 73  <- this is 'as'
0d 0a  <- CR-LF newline characters
62 71  <- this is 'bq'
0d 0a  <- CR-LF
0d 0a  <- CR-LF for empty line
64 66  <- `df`

That's 12. Note that your last line does not have a CR-LF pair.

Upvotes: 6

Related Questions