unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: undecided vs utf-8
Date: Fri, 05 Nov 2010 13:42:29 +0900	[thread overview]
Message-ID: <tl78w18v0sq.fsf@m17n.org> (raw)
In-Reply-To: <m362wco5zx.fsf@quimbies.gnus.org> (message from Lars Magne Ingebrigtsen on Fri, 05 Nov 2010 03:32:02 +0100)

In article <m362wco5zx.fsf@quimbies.gnus.org>, Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Kenichi Handa <handa@m17n.org> writes:
> > It's perhaps because you are in some of iso-8859-1 locale.

> I don't think I am, but I might be wrong.  There are so many locale
> variables, but I always try to put my machines into "C" locale.

??? When the locale is "C", emacs prefers utf-8 the most.

% LANG=C emacs -Q -batch --eval '(message "%s" (car (coding-system-priority-list)))'

should prints utf-8.

> > I don't want to add such a heuristic in
> > decode-coding-string/region (the lowest functions available
> > from Lisp).  Please note that above sequence is also valid
> > as Big5.  If people are in Big5 locale, it's hard to answer
> > which of utf-8 or big5 is preferred unless we implement NLP
> > system.

> I don't know how the big5 encoding looks like, but when it comes to
> iso-8859-1 vs utf-8, then there are many utf-8 strings that are valid
> iso-8859-1 strings, but there are few iso-8859-1 strings that are valid
> utf-8 strings.  Therefore it seems to make sense to prefer utf-8 over
> iso-8859-1.  Perhaps.

Please consider the reason why one is in iso-8859-1 locale
nowadays.  Isn't it because he prefers iso-8859-1 orver
utf-8?

> > Perhaps making an upper layer function that will accept a
> > list of preferred coding systems will be good; something
> > like this.
> >
> > (defun detect-and-decode-coding-string (str preferred)
> >   (let ((detected (detect-coding-string str))
> > 	decided)
> >     (while (and preferred (not decided)) 
> >       (if (memq (car preferred) detected)
> > 	  (setq decided (car preferred))
> > 	(setq preferred (cdr preferred))))
> >     (decode-coding-string str (or decided (car detected)))))

> Well, this is about `undecided', and the C layer does DWIM-ish
> processing when you ask it to decode `undecided', doesn't it?

I don't know which Emacs' behaviour you describe as DWIM-ish.

> The use case that made me look into this -- erc -- is somewhat special.
> The irc protocol does no charset tagging, and some clients send some
> charsets, and some send others, which is why erc uses `undecided' as the
> default coding system.  Typically on a channel you'll see somebody using
> a local (iso-8859-* is popular) charset, and others using utf-8.

> Perhaps the fix here isn't to do anything with `undecided' per se, but
> just fix erc.  It's trivial enough -- just have the default be, say,
> `undecided-or-utf-8', and then handle that by running
> `detect-coding-string' over it, see whether it's utf-8, and then either
> use that or pass `undecided' down into the decoding functions.

> I don't know.  What do you think?

I think the best way is to provide users an easy way to
specify a correct coding-system when they see a decoding
error as well as the method to customize the default
coding-system for erc.

---
Kenichi Handa
handa@m17n.org



  reply	other threads:[~2010-11-05  4:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-04 22:27 undecided vs utf-8 Lars Magne Ingebrigtsen
2010-11-04 22:40 ` Lars Magne Ingebrigtsen
2010-11-05  0:02   ` Stefan Monnier
2010-11-05  8:01     ` Eli Zaretskii
2010-11-05  2:01 ` Kenichi Handa
2010-11-05  2:32   ` Lars Magne Ingebrigtsen
2010-11-05  4:42     ` Kenichi Handa [this message]
2010-11-05 13:02       ` Lars Magne Ingebrigtsen
2010-11-05  8:09     ` Eli Zaretskii
2010-11-05 13:06       ` Lars Magne Ingebrigtsen
2010-11-05  8:10     ` Eli Zaretskii
2010-11-05 12:28       ` Deniz Dogan
2010-11-05 12:50       ` Lars Magne Ingebrigtsen
2010-11-05  7:56 ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=tl78w18v0sq.fsf@m17n.org \
    --to=handa@m17n.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).