help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to "asciify" a string?


From: Teemu Likonen
Subject: Re: Is there a way to "asciify" a string?
Date: Sun, 27 May 2018 15:52:58 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Marcin Borkowski [2018-05-27 14:36:27+02] wrote:

> Still, I need something *simple*. I have a person's name (possibly
> with some national characters), and I want to derive a filename from
> it. It doesn't have to be correct in 100% cases. It doesn't even have
> to be unambiguous (there will be a number for that in the filename,
> too).

> (BTW, if there is some command-line utility to do that, that's fine
> too.)

There is iconv:

    $ echo áàãä | iconv -t ASCII//TRANSLIT
    aaaa

So an Emacs Lisp wrapper function for iconv can be written like this:

    (defun my-iconv-ascii-translit (string)
      (with-temp-buffer
        (insert string)
        (call-process-region (point-min) (point-max)
                             "iconv" t t nil "-t" "ASCII//TRANSLIT")
        (buffer-substring-no-properties (point-min) (point-max))))

-- 
/// Teemu Likonen   - .-..   <https://keybase.io/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]