all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: bug-gnu-emacs@gnu.org
Subject: Re: detect-coding-string doesn't return all possibilities
Date: Fri, 14 Mar 2003 13:55:17 +0900 (JST)	[thread overview]
Message-ID: <200303140455.NAA22653@etlken.m17n.org> (raw)
In-Reply-To: <m3adfyefc7.fsf@defun.localdomain> (message from Jesper Harder on Fri, 14 Mar 2003 05:34:32 +0100)

In article <m3adfyefc7.fsf@defun.localdomain>, Jesper Harder <harder@ifa.au.dk> 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

  reply	other threads:[~2003-03-14  4:55 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
2003-03-14  4:55     ` Kenichi Handa [this message]
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

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

  git send-email \
    --in-reply-to=200303140455.NAA22653@etlken.m17n.org \
    --to=handa@m17n.org \
    --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 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.