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

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

Re: How to convert an arbitrary string into a filename


From: Yuri Khan
Subject: Re: How to convert an arbitrary string into a filename
Date: Wed, 26 Apr 2023 12:42:38 +0700

On Wed, 26 Apr 2023 at 10:56, Marcin Borkowski <mbork@mbork.pl> wrote:

> given an arbitrary string, say "Hello, world!!!", I want to have
> a filename with all the runs of weird characters (that is,
> non-alphanumeric ones) converted to dashes (say, "Hello-world").  Is
> there a function for that in Emacs already or should I write my own?

It looks like you want to generate file names for blog posts or
articles so that URLs look pretty. While a useful goal, the mechanic
you ask for is lossy, so multiple titles could map into the same file
name, which, in the worst case, could lead to data loss, or require
disambiguation of some kind.

(Also, depending on how wide your audience is and what your
implementation’s definition of alphanumeric is, it might turn titles
written in non-Latin-based scripts into an empty string, and fixing
that might be moderately easy for some scripts (e.g. Greek, Cyrillic)
and hard for others (e.g. CJK).)



reply via email to

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