all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Richard Copley <rcopley@gmail.com>
Cc: 22436@debbugs.gnu.org
Subject: bug#22436: read-coding-system uses wrong default when called from write-file
Date: Sat, 23 Jan 2016 13:31:59 +0200	[thread overview]
Message-ID: <83h9i45y6o.fsf@gnu.org> (raw)
In-Reply-To: <CAPM58ojw5VxXFrTnBAW4MwBAPGEP8TmC1aX7jTrc7DODFnDLsA@mail.gmail.com> (message from Richard Copley on Sat, 23 Jan 2016 09:45:39 +0000)

> From: Richard Copley <rcopley@gmail.com>
> Date: Sat, 23 Jan 2016 09:45:39 +0000
> Cc: 22436@debbugs.gnu.org
> 
> > An encoding can be considered "wrong" if it fails to encode a
> > character.  AFAICS, chinese-iso-8bit does succeed in encoding it, so
> > the above definition of "wrong" doesn't fit.
> 
> It encodes the character to #xa1 #xae . When I open the file that is
> decoded as "¡®", without asking any questions. Isn't that what you
> saw? Are you going to tell me that's right too?

Emacs never asks questions when decoding text, only when encoding it.
When it visits a file, it guesses the encoding as best it can, and
that's what you see.

If you type "C-x RET c chinese-iso-8bit RET C-x C-f FILE RET", do you
see that character correctly decoded and correctly displayed?

> > In addition, there should be a *Warning* buffer displayed where you
> > have a long list of encodings Emacs knows about that can encode this
> > character; chinese-iso-8bit is just one of them, but the text there
> > tells you to select any one of them.  Do you see that buffer
> > displayed?
> 
> Yes, but chinese-iso-8bit is not on the list.

It is: that's the first one in the list, gb2312.  It's an alias for
chinese-iso-8bit, which is the formal name.

> > Given all this information, please do tell why you think what Emacs
> > did was wrong,
> 
> Do you seriously think it's the right thing to do? That's the last thing
> I expected. I don't know how to respond.
> 
> > and what did you think Emacs should have done instead.
> 
> I think Emacs should pick something less surprising and unhelpful,
> like utf-8.

Unless it gets some hint from the locale or from customizations, Emacs
does not prefer any encoding to any other encoding.  GB2312 is a very
reasonable choice in some locales, and might be what you want.  How is
Emacs to know, if your locale is US English?  All it knows is that
your default encoding cannot be used.

What Emacs did here is produce a list of all the encodings that can
encode that character, sorted them according what it knows about your
preferences (which is nothing in this case), and then picked up the
first encoding in the resulting list.  And that's what you see.  UTF-8
is also in the list, but it comes later.

If you want Emacs to prefer UTF-8, you can have that.  Just type

  M-x prefer-coding-system RET utf-8 RET

That's it, Emacs will from now on use UTF-8 whenever it can without
asking.  If you repeat your recipe after setting that preference, it
will silently encode the buffer/region with UTF-8, no questions asked.

You can have this customization in your ~/.emacs file, of course, if
you want it permanent.





  reply	other threads:[~2016-01-23 11:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22 19:31 bug#22436: read-coding-system uses wrong default when called from write-file Richard Copley
2016-01-22 21:23 ` Eli Zaretskii
2016-01-22 23:23   ` Richard Copley
2016-01-23  5:56     ` Eli Zaretskii
2016-01-23  9:45       ` Richard Copley
2016-01-23 11:31         ` Eli Zaretskii [this message]
2016-01-23 11:53           ` Richard Copley
2016-01-23 13:09             ` Eli Zaretskii
2016-01-23 13:12       ` Lars Magne Ingebrigtsen
2016-01-23 13:46         ` Eli Zaretskii
2016-01-23 13:55           ` Lars Magne Ingebrigtsen
2016-01-23 14:39             ` Eli Zaretskii
2016-01-25 22:38               ` Richard Copley
2016-01-26 15:39                 ` Eli Zaretskii

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=83h9i45y6o.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=22436@debbugs.gnu.org \
    --cc=rcopley@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.