[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: national to ASCII character conversion
From: |
Teemu Likonen |
Subject: |
Re: national to ASCII character conversion |
Date: |
Wed, 17 Jun 2009 22:09:04 GMT |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux) |
On 2009-06-17 21:26 (UTC), Teemu Likonen wrote:
> On 2009-06-17 22:34 (+0200), Michal wrote:
>> I have a string which contains national characters and I would like
>> to convert them to ASCII equivalents.
> In Lisp it would be something like this:
Ok, let's turn it into a function:
(defun my-ascii-translit (string)
"Turn STRING to Ascii and transliterate non-Ascii chars."
(with-temp-buffer
(insert string)
(shell-command-on-region (point-min) (point-max)
"/usr/bin/iconv -t ASCII//TRANSLIT"
(current-buffer) t)
(buffer-substring-no-properties (point-min) (point-max))))
The function returns asciified version of its argument string:
(my-ascii-translit "ółż € —")
=> "olz EUR --"