24

I'm using File Explorer to monitor file size in Windows.

I have a .dat file and when I type normal characters like letters the file size increases by 1 byte but when I press enter the file size increases by 2 bytes.

Why does the file size increase by 2 bytes when I press enter?

Laurel
  • 168
  • 1
  • 8

2 Answers2

68

Windows uses both Carriage Return \r and Line Feed \n to signify a new line, unlike UNIX (which uses \n).

See also Does Windows carriage return \r\n consist of two characters or one character?
and Why does Windows use CR LF?

JoSSte
  • 495
Tetsujin
  • 50,917
6

Because pressing "Enter" does not write one character, as you might expect, but two. Those two characters are, in hexadecimal, 0x0D and 0x0A. The first one returns the cursor to the beginning of the line, and the second moves the cursor one line below.