all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Angelo Graziosi <angelo.graziosi@alice.it>,
	Yuri Khan <yuri.v.khan@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Characters saved mismatch?
Date: Sun, 07 May 2017 12:46:48 +0000	[thread overview]
Message-ID: <CAFyQvY2JTR1z6eXNNiOQD594Jy1NSRN7FCFZ30f6MVk5fxKCvA@mail.gmail.com> (raw)
In-Reply-To: <e30f6817-1cee-d4a1-2ff6-d4539f5a8f4a@alice.it>

[-- Attachment #1: Type: text/plain, Size: 1247 bytes --]

On Sun, May 7, 2017, 5:16 AM Angelo Graziosi <angelo.graziosi@alice.it>
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

[-- Attachment #2: Type: text/html, Size: 2437 bytes --]

  parent reply	other threads:[~2017-05-07 12:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-06 23:27 Characters saved mismatch? Angelo Graziosi
2017-05-07  1:06 ` Paul Eggert
2017-05-07  2:53   ` Kaushal Modi
2017-05-07  8:06   ` Angelo Graziosi
2017-05-07  8:52     ` Stephen Berman
2017-05-07  9:02       ` Angelo Graziosi
2017-05-07  8:56 ` Yuri Khan
2017-05-07  9:15   ` Angelo Graziosi
2017-05-07  9:25     ` Yuri Khan
2017-05-07 10:50       ` Angelo Graziosi
2017-05-07 12:41         ` Yuri Khan
2017-05-07 12:46     ` Kaushal Modi [this message]
2017-05-07 13:38       ` Angelo Graziosi
2017-05-07 14:07         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY2JTR1z6eXNNiOQD594Jy1NSRN7FCFZ30f6MVk5fxKCvA@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=angelo.graziosi@alice.it \
    --cc=emacs-devel@gnu.org \
    --cc=yuri.v.khan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.