emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Characters saved mismatch?


From: Kaushal Modi
Subject: Re: Characters saved mismatch?
Date: Sun, 07 May 2017 12:46:48 +0000

On Sun, May 7, 2017, 5:16 AM Angelo Graziosi <address@hidden> wrote:


Someone should explain the meaning of "Wrote ‘c:/msys64/tmp/foo.text’ (8
characters)".

As others stated, that's because each newline is counted as 1 character too. 

If it refers to the number of characters, my example contains 6
characters: f-o-o-b-a-r and not 8.

No, it contains 8 characters:

1. f
2. o
3. o
4. Newline (Just 1 character, does not matter if it is 1 byte on unix or 2 bytes on Windows. This is character count, not byte count.)
5. b
6. a
7. r
8. Newline

As I wrote, in Windows Emacs uses DOS style, more precisely 'utf-8-dos'.
That should mean 1 byte/ch and CR+LF for end line (RET). This mean that

foo RET
bar RET

should contain (3+2) * 2 = 10 bytes as, 'ls' shows..

As written about emacs sees the newline as just 1 character. Emacs is printing character count, while ls is printing byte count, and thus the difference. 

Visualize that newline character as just 1 character as the "\n" used in regexps to match newlines. 

Then, where does "Wrote ‘c:/msys64/tmp/foo.text’ (8 characters)" came
from, on Windows?

As explained above. 
--

Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]