From: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: Using quail input methods to translate buffer text.
Date: Fri, 07 Jul 2006 10:40:12 +0900 [thread overview]
Message-ID: <E1FyfKG-0001ie-00@etlken> (raw)
In-Reply-To: <87k66rlqys.fsf@heslin.eclipse.co.uk> (message from Peter Heslin on Wed, 05 Jul 2006 21:46:51 +0100)
In article <87k66rlqys.fsf@heslin.eclipse.co.uk>, Peter Heslin <pj@heslin.eclipse.co.uk> 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") => "абцд"
You don't need the last decode-coding-string if you use
emacs-unicode-2.
---
Kenichi Handa
handa@m17n.org
next prev parent reply other threads:[~2006-07-07 1:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-05 20:46 Using quail input methods to translate buffer text Peter Heslin
2006-07-06 12:11 ` Evil Boris
2006-07-07 1:40 ` Kenichi Handa [this message]
2006-07-07 12:25 ` Peter Heslin
2006-07-07 12:29 ` Kenichi Handa
2006-07-07 22:36 ` Peter Heslin
2006-07-08 0:48 ` Miles Bader
2006-07-08 0:54 ` Miles Bader
2006-07-10 21:12 ` Peter Heslin
2006-07-18 1:13 ` Kenichi Handa
2006-07-20 17:40 ` Peter Heslin
2006-07-21 2:50 ` Kenichi Handa
2006-07-21 2:56 ` Miles Bader
2006-07-21 4:16 ` Kenichi Handa
2006-07-21 16:21 ` Richard Stallman
2006-07-24 1:41 ` Kenichi Handa
2006-07-24 18:22 ` Richard Stallman
2006-07-25 7:16 ` Kenichi Handa
2006-07-25 14:13 ` Richard Stallman
2006-07-26 0:19 ` Kenichi Handa
2006-07-26 19:52 ` Peter Heslin
2006-07-23 21:30 ` Peter Heslin
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1FyfKG-0001ie-00@etlken \
--to=handa@m17n.org \
--cc=emacs-devel@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).