From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.bugs Subject: Re: detect-coding-string doesn't return all possibilities Date: Fri, 14 Mar 2003 13:55:17 +0900 (JST) Sender: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <200303140455.NAA22653@etlken.m17n.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1047617829 31089 80.91.224.249 (14 Mar 2003 04:57:09 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 14 Mar 2003 04:57:09 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 14 05:57:08 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18thFj-00085A-00 for ; Fri, 14 Mar 2003 05:57:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18thEo-0000j9-01 for gnu-bug-gnu-emacs@m.gmane.org; Thu, 13 Mar 2003 23:56:10 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18thEM-0000Ae-00 for bug-gnu-emacs@gnu.org; Thu, 13 Mar 2003 23:55:42 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18thE8-0007xG-00 for bug-gnu-emacs@gnu.org; Thu, 13 Mar 2003 23:55:29 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18thE7-0007mS-00 for bug-gnu-emacs@gnu.org; Thu, 13 Mar 2003 23:55:27 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h2E4tH908813; Fri, 14 Mar 2003 13:55:17 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h2E4tHA11236; Fri, 14 Mar 2003 13:55:17 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id NAA22653; Fri, 14 Mar 2003 13:55:17 +0900 (JST) Original-To: harder@ifa.au.dk In-reply-to: (message from Jesper Harder on Fri, 14 Mar 2003 05:34:32 +0100) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: bug-gnu-emacs-bounces+gnu-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:4609 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:4609 In article , Jesper Harder writes: > 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." > ...) How about this? (defun decode-coding-string-safely (string coding-system) "Decode STRING by CODING-SYSYTEM and return the result. If STRING contains invalid byte sequence for CODING-SYSTEM, return nil." (let* ((decoded (decode-coding-string str coding-system)) (charsets (find-charset-string decoded))) (and (not (memq 'eight-bit-control charsets)) (not (memq 'eight-bit-graphic charsets)) decoded))) --- Ken'ichi HANDA handa@m17n.org