all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: emacs-pretest-bug@gnu.org, ihs_4664@yahoo.com,
	emacs-devel@gnu.org, richard.stallman@gnu.org,
	christopher.ian.moore@gmail.com
Subject: Re: Emacs puts binary junk into the clipboard, marking it as text
Date: Thu, 19 Oct 2006 09:19:25 +0200	[thread overview]
Message-ID: <453726FD.7070308@swipnet.se> (raw)
In-Reply-To: <E1GPrhb-0006Ox-00@etlken>



Kenichi Handa wrote:

> This will be useful for checking UTF-8 validity.
> 
> (define-ccl-program ccl-check-utf-8
>   '(0
>     ((r0 = 1)
>      (loop
>       (read-if (r1 < #x80) (repeat)
> 	((r0 = 0)
> 	 (if (r1 < #xC2) (end))
> 	 (read r2)
> 	 (if ((r2 & #xC0) != #x80) (end))
> 	 (if (r1 < #xE0) ((r0 = 1) (repeat)))
> 	 (read r2)
> 	 (if ((r2 & #xC0) != #x80) (end))
> 	 (if (r1 < #xF0) ((r0 = 1) (repeat)))
> 	 (read r2)
> 	 (if ((r2 & #xC0) != #x80) (end))
> 	 (if (r1 < #xF8) ((r0 = 1) (repeat)))
> 	 (read r2)
> 	 (if ((r2 & #xC0) != #x80) (end))
> 	 (if (r1 == #xF8) ((r0 = 1) (repeat)))
> 	 (end))))))
>   "Check if the input unibyte string is a valid UTF-8 sequence or not.
> If it is valid, set the register `r0' to 1, else set it to 0.")
> 
> (defun string-utf-8-p (string)
>   "Return non-nil iff STRING is a unibyte string of valid UTF-8 sequence."
>   (if (or (not (stringp string))
> 	  (multibyte-string-p string))
>       (error "Not a unibyte string: %s" string))
>   (let ((status (make-vector 9 0)))
>     (ccl-execute-on-string ccl-check-utf-8 status string)
>     (= (aref status 0) 1)))
> 
> 


Thanks.  I used them to check for UTF-8.  We now decline selection requests 
for UTF8_STRING if the data is not in UTF-8.

	Jan D.

      reply	other threads:[~2006-10-19  7:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1158280855.14121.69.camel@chrislap.madeupdomain.com>
2006-09-15  7:07 ` Emacs puts binary junk into the clipboard, marking it as text Jan Djärv
2006-09-15 16:30   ` Kevin Rodgers
2006-09-16 11:31     ` Jan D.
2006-09-16 17:25       ` Jan D.
2006-09-19  5:05         ` Kenichi Handa
2006-09-19  6:15           ` Jan Djärv
2006-09-19  7:14             ` Kenichi Handa
2006-09-19 10:54           ` Stefan Monnier
2006-09-19 11:14             ` Kenichi Handa
2006-09-19 16:15               ` Stefan Monnier
2006-09-19 19:32                 ` Jan D.
2006-09-20  2:20                 ` Kenichi Handa
2006-10-19  7:19                   ` Jan Djärv [this message]

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=453726FD.7070308@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=christopher.ian.moore@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=ihs_4664@yahoo.com \
    --cc=richard.stallman@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.