{asciiname:string:encoding}

Description

Converts any text into a lowercase ASCII-only string suitable for a username, filename, or URL fragment. It transliterates accented and non-ASCII letters to their plain ASCII equivalents (for example e-acute becomes e, z-caron becomes z), lowercases everything, and replaces every character that is not a letter, digit, hyphen, or underscore with a hyphen. Runs of separators collapse to a single one and leading or trailing hyphens are trimmed. Letters, digits, hyphens and underscores survive; dots and all other punctuation are turned into hyphens. The optional second parameter names the SOURCE character set of the input (default utf-8); set it to windows-1250 or iso-8859-2 only when the input bytes are in that legacy encoding rather than UTF-8. For a slug that also keeps dots, enforces uniqueness, or trims length, use seoname instead.

Parameters

string required default (empty)

The text to convert. Any string; accented and non-ASCII letters are transliterated to plain ASCII.

encoding optional default utf-8

Source character encoding of the input, used to transliterate accented letters to ASCII. Set to windows-1250 or iso-8859-2 only when the input bytes are in that legacy encoding rather than UTF-8.

Examples

test{asciiname:Hello World}
Expectedhello-world
Actualhello-world
Spaces become hyphens and the result is lowercased.
test{asciiname:Café Restaurant}
Expectedcafe-restaurant
Actualcafe-restaurant
Accented letters are transliterated to plain ASCII, so e-acute becomes e.
test{asciiname:Žluťoučký kůň}
Expectedzlutoucky-kun
Actualzlutoucky-kun
Czech diacritics are removed. The numeric entities decode to the accented letters, which transliterate to ASCII.
test{asciiname:report.final_v2}
Expectedreport-final_v2
Actualreport-final_v2
Underscores survive; dots and other punctuation become hyphens. Use seoname when you need to keep dots in the slug.
test{asciiname:--100% Done!--}
Expected100-done
Actual100-done
Runs of separators collapse to a single hyphen and leading or trailing hyphens are trimmed.
test{asciiname:{item:5726c2c6b035d7aab450d1794e9e90d7:_#HEADLINE}}
Expectedgamma
Actualgamma
The canonical use: build a slug or filename from a field value. Here it reads the headline of a fixture item (Gamma) and slugifies it.