From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: Using quail input methods to translate buffer text. Date: Fri, 07 Jul 2006 10:40:12 +0900 Message-ID: References: <87k66rlqys.fsf@heslin.eclipse.co.uk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1152236477 17087 80.91.229.2 (7 Jul 2006 01:41:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 7 Jul 2006 01:41:17 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 07 03:41:12 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FyfL8-0007di-Ez for ged-emacs-devel@m.gmane.org; Fri, 07 Jul 2006 03:41:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FyfL7-0004v2-VW for ged-emacs-devel@m.gmane.org; Thu, 06 Jul 2006 21:41:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FyfKw-0004ux-7t for emacs-devel@gnu.org; Thu, 06 Jul 2006 21:40:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FyfKt-0004ul-SK for emacs-devel@gnu.org; Thu, 06 Jul 2006 21:40:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FyfKt-0004ui-Nh for emacs-devel@gnu.org; Thu, 06 Jul 2006 21:40:51 -0400 Original-Received: from [150.29.246.133] (helo=mx1.aist.go.jp) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FyfLC-0000Ws-Gs for emacs-devel@gnu.org; Thu, 06 Jul 2006 21:41:11 -0400 Original-Received: from smtp3.aist.go.jp ([150.29.246.12]) by mx1.aist.go.jp with ESMTP id k671elwU020788; Fri, 7 Jul 2006 10:40:47 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp3.aist.go.jp with ESMTP id k671efLd022204; Fri, 7 Jul 2006 10:40:42 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken with local (Exim 3.36 #1 (Debian)) id 1FyfKG-0001ie-00; Fri, 07 Jul 2006 10:40:12 +0900 Original-To: Peter Heslin In-reply-to: <87k66rlqys.fsf@heslin.eclipse.co.uk> (message from Peter Heslin on Wed, 05 Jul 2006 21:46:51 +0100) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.50 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:56680 Archived-At: In article <87k66rlqys.fsf@heslin.eclipse.co.uk>, Peter Heslin writes: > I have some ascii text that I want to convert to utf-8, and it is > encoded in a manner just like one of the quail input methods. Can > anyone tell me if there is a function that will take text from a buffer > and treat it as if it were input as keystrokes to quail, and then output > the result in Unicode? We don't have such a function, but this will work in many cases. (defun temp (input-method key-string) (let ((str "")) (activate-input-method input-method) (setq unread-command-events (string-to-list key-string)) (while unread-command-events (let ((key (car unread-command-events)) events) (setq unread-command-events (cdr unread-command-events)) (setq events (funcall input-method-function key)) (dolist (elt events) (if (integerp elt) (setq str (concat str (string elt))))))) (activate-input-method nil) (decode-coding-string (encode-coding-string str 'utf-8) 'utf-8))) For example: (temp "cyrillic-yawerty" "abcd") =3D> "=D0=B0=D0=B1=D1=86=D0=B4" You don't need the last decode-coding-string if you use emacs-unicode-2. --- Kenichi Handa handa@m17n.org