From: Jesper Harder <harder@ifa.au.dk>
Cc: bug-gnu-emacs@gnu.org
Subject: Re: detect-coding-string doesn't return all possibilities
Date: Fri, 14 Mar 2003 05:34:32 +0100 [thread overview]
Message-ID: <m3adfyefc7.fsf@defun.localdomain> (raw)
In-Reply-To: <mailman.3161.1047557974.21513.bug-gnu-emacs@gnu.org> (Kenichi Handa's message of "Thu, 13 Mar 2003 20:34:27 +0900 (JST)")
[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]
Kenichi Handa <handa@m17n.org> writes:
> detect-coding-string doesn't return all possible coding systems, but
> returns a possible coding systems Emacs may automatically detect in
> the current language environment.
Ah, I see.
Do you know of any other way to decide if using a given coding system
for decoding a string would give a valid result?
A function similar to this would be really useful:
(defun possible-coding-system-for-string-p (str coding-system)
"Return t if CODING-SYSTEM is a possible coding system for decoding
STR."
...)
The issue comes from a discussion on the Gnus development list (I've
included one of the messages from that thread below).
Gnus does not work very well when using CVS Emacs in an UTF-8 locale,
because a lot of non-MIME capable clients don't include proper charset
information. This causes Gnus to decode many Latin-1 strings as UTF-8.
It would help a lot if we could detect that a string cannot possibly be
encoded in UTF-8. I know that it's not always possible to distinguish,
but just detecting strings that are invalid as UTF-8 would be very
helpful. This doesn't just apply to UTF-8 but to any coding system, of
course.
> But the docstring of detect-coding-system is surely not
> good. I've just changed the first paragraph as this. How
> is it?
It's good.
[-- Attachment #2: Type: message/rfc822, Size: 2704 bytes --]
From: Jesper Harder <harder@myrealbox.com>
Subject: Re: charset=macintosh
Date: Sun, 09 Mar 2003 04:56:44 +0100
Message-ID: <m3adg5w5tv.fsf@defun.localdomain>
Simon Josefsson <jas@extundo.com> writes:
> But what if you are saying about UTF-8 clients being MIME capable is
> true, and since UTF-8 is typically never preferred by current emacsen,
> doesn't emacs' current guessing works the best we can hope for?
> Doesn't it detect among ISO-8859-X, ISO-2022 and Big5 properly?
No. I was hoping we could do something like this (for headers):
(let ((coding-systems (detect-coding-string string)))
(if (memq default coding-systems)
(decode-coding-string string default)
(decode-coding-string string (car coding-systems))))
i.e. if the default coding system is valid for the string, then use
that; otherwise use whatever Emacs thinks is the most likely coding
system. I think this would be ideal.
But unfortunately `detect-coding-string' _doesn't_ return a complete
list of possible coding systems. Consider this scenario:
I'm using Emacs in a Latin-1 locale. dk.* newsgroups work fine
because latin-1 is the default. But I also subscribe to, say, a few
Korean newsgroups. The entry in `gnus-groups-charset-alist':
("\\(^\\|:\\)han\\>" euc-kr)
should take care of selecting the proper default charset. But *oops*,
`detect-coding-string' doesn't think that euc-kr is a possible charset
for a Korean string encoded in euc-kr:
(detect-coding-string (encode-coding-string "안녕" 'euc-kr))
=> (iso-latin-1 iso-latin-1 raw-text japanese-shift-jis
chinese-big5 no-conversion)
So the above approach would fail.
> 2) Users with emacs in UTF-8 prefers UTF-8 too often, even when the
> data is invalid UTF-8 and another encoding should be selected.
>
> The second situation is a bug, and I hope we can fix this.
Yep, 2) is the most serious problem. Especially because more and more
people are (often unknowingly) using an UTF-8 locale because Redhat 8
switched to UTF-8 by default. Those people would experience Gnus as
broken when reading hierarchies like dk.* or de.*.
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs
next prev parent reply other threads:[~2003-03-14 4:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-09 17:07 detect-coding-string doesn't return all possibilities Jesper Harder
2003-03-13 11:34 ` Kenichi Handa
[not found] ` <mailman.3161.1047557974.21513.bug-gnu-emacs@gnu.org>
2003-03-14 4:34 ` Jesper Harder [this message]
2003-03-14 4:55 ` Kenichi Handa
2003-03-14 23:04 ` Jesper Harder
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=m3adfyefc7.fsf@defun.localdomain \
--to=harder@ifa.au.dk \
--cc=bug-gnu-emacs@gnu.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).