From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Jan_Dj=E4rv?= Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.devel Subject: Re: Emacs puts binary junk into the clipboard, marking it as text Date: Thu, 19 Oct 2006 09:19:25 +0200 Message-ID: <453726FD.7070308@swipnet.se> References: <1158280855.14121.69.camel@chrislap.madeupdomain.com> <450A514E.6020205@swipnet.se> <450BE084.10905@swipnet.se> <450C3380.2050008@swipnet.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1161242653 6488 80.91.229.2 (19 Oct 2006 07:24:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 Oct 2006 07:24:13 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, ihs_4664@yahoo.com, emacs-devel@gnu.org, richard.stallman@gnu.org, christopher.ian.moore@gmail.com Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Thu Oct 19 09:24:10 2006 Return-path: Envelope-to: gebp-emacs-pretest-bug@gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GaSFx-0000w0-Ar for gebp-emacs-pretest-bug@gmane.org; Thu, 19 Oct 2006 09:23:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GaSCq-0000qY-SY for gebp-emacs-pretest-bug@gmane.org; Thu, 19 Oct 2006 03:20:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GaSBx-0007wN-5E for emacs-pretest-bug@gnu.org; Thu, 19 Oct 2006 03:19:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GaSBv-0007sm-IF for emacs-pretest-bug@gnu.org; Thu, 19 Oct 2006 03:19:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GaSBs-0007oJ-4J; Thu, 19 Oct 2006 03:19:44 -0400 Original-Received: from [81.228.9.186] (helo=av9-2-sn3.vrr.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GaSBr-0004Z5-V8; Thu, 19 Oct 2006 03:19:44 -0400 Original-Received: by av9-2-sn3.vrr.skanova.net (Postfix, from userid 502) id 2D206380E7; Thu, 19 Oct 2006 09:19:43 +0200 (CEST) Original-Received: from smtp3-1-sn3.vrr.skanova.net (smtp3-1-sn3.vrr.skanova.net [81.228.9.101]) by av9-2-sn3.vrr.skanova.net (Postfix) with ESMTP id 188A0380E4; Thu, 19 Oct 2006 09:19:43 +0200 (CEST) Original-Received: from coolsville.localdomain (81-235-205-78-no59.tbcn.telia.com [81.235.205.78]) by smtp3-1-sn3.vrr.skanova.net (Postfix) with ESMTP id 4497637E43; Thu, 19 Oct 2006 09:19:42 +0200 (CEST) User-Agent: Thunderbird 1.5.0.7 (X11/20060913) Original-To: Kenichi Handa In-Reply-To: X-BeenThere: emacs-pretest-bug@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for CVS Emacs." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.pretest.bugs:14672 gmane.emacs.devel:60907 Archived-At: 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.