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: Eli Zaretskii
Subject: Re: Is there a way to "asciify" a string?
Date: Sun, 27 May 2018 19:07:40 +0300

> From: Teemu Likonen <tlikonen@iki.fi>
> Date: Sun, 27 May 2018 15:52:58 +0300
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> > (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))))

Come on, crowd, you _must_ know that Emacs has all of the iconv's
functionality (and more) built-in, right?  All that encode-coding
stuff etc.?

Btw, ASCII//TRANSLIT doesn't necessarily guarantee it will succeed in
removing all the diacritics, AFAIK.  You need to completely decompose
the characters for that, and AFAIK iconv doesn't have such
capabilities.  (Emacs does.)



reply via email to

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