[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ncr (numeric character reference) to unicode
From: |
Stephen Berman |
Subject: |
Re: ncr (numeric character reference) to unicode |
Date: |
Wed, 15 Apr 2009 23:43:20 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) |
On Tue, 14 Apr 2009 11:42:09 -0500 "B. T. Raven" <nihil@nihilo.net> wrote:
> Miles Bader wrote:
>> "B. T. Raven" <nihil@nihilo.net> 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
- ncr (numeric character reference) to unicode, B. T. Raven, 2009/04/13
- Re: ncr (numeric character reference) to unicode, Eli Zaretskii, 2009/04/13
- Re: ncr (numeric character reference) to unicode, Miles Bader, 2009/04/13
- Re: ncr (numeric character reference) to unicode, Kevin Rodgers, 2009/04/16
- Message not available
- Re: ncr (numeric character reference) to unicode, B. T. Raven, 2009/04/16
- Re: ncr (numeric character reference) to unicode, Stephen Berman, 2009/04/17
- Message not available
- Re: ncr (numeric character reference) to unicode, B. T. Raven, 2009/04/17