From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: ncr (numeric character reference) to unicode Date: Wed, 15 Apr 2009 23:43:20 +0200 Message-ID: <87y6u1d24n.fsf@escher.local.home> References: <5-WdnWGdu7Z1AH7UnZ2dnUVZ_vmdnZ2d@sysmatrix.net> <3LydnaCSF_RDIXnUnZ2dnUVZ_s-dnZ2d@sysmatrix.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239831861 18926 80.91.229.12 (15 Apr 2009 21:44:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Apr 2009 21:44:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 15 23:45:41 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LuCvE-0001hw-US for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Apr 2009 23:45:33 +0200 Original-Received: from localhost ([127.0.0.1]:36951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuCtq-0006zC-An for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Apr 2009 17:44:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuCtR-0006yt-HU for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 17:43:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuCtM-0006y4-SK for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 17:43:40 -0400 Original-Received: from [199.232.76.173] (port=41225 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuCtM-0006xv-GM for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 17:43:36 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:55134 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuCtL-0001Po-W0 for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 17:43:36 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LuCtH-00053n-6Y for help-gnu-emacs@gnu.org; Wed, 15 Apr 2009 21:43:31 +0000 Original-Received: from i59f5bb0e.versanet.de ([89.245.187.14]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Apr 2009 21:43:31 +0000 Original-Received: from stephen.berman by i59f5bb0e.versanet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Apr 2009 21:43:31 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: i59f5bb0e.versanet.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:63764 Archived-At: On Tue, 14 Apr 2009 11:42:09 -0500 "B. T. Raven" wrote: > Miles Bader wrote: >> "B. T. Raven" writes: >>> Does any of you know whether nxhtml has the capability to convert >>> sequences like this: >>> >>> שַׁלוֹם. >>> (shalom in Hebrew) >> >> The following should work: >> >> (defun expand-html-encoded-chars (start end) >> (interactive "r") >> (save-excursion >> (goto-char start) >> (while (re-search-forward "&#\\([0-9]+\\);" end t) >> (replace-match (char-to-string >> (decode-char 'ucs (string-to-number (match-string 1))) ) >> t t)))) >> >> -Miles >> > > Thanks, Eli and Miles. The conversion works fine (with uncomposed glyphs, that > is, points as separate characters, same as in the html codes). I referenced > the command in an alias: > > (defalias 'xhc 'expand-html-encoded-chars) > > and then tried to do the same with this function: > > (defun reverse-string (beg end) > (interactive "r") > (setq str (buffer-substring beg end)) > (apply #'string (nreverse (string-to-list str)))) > > but it doesn't seem to work, although it doesn't produce errors in a traceback > buffer. What am I missing? > > Thanks, > > Ed Does this do what you want? (defun reverse-string (beg end) (interactive "r") (xhc beg end) (let* ((beg (region-beginning)) (end (region-end)) (str1 (buffer-substring beg end)) (str2 (apply #'string (nreverse (string-to-list str1))))) (replace-string str1 str2 nil beg end))) Steve Berman