Skip to content

Instantly share code, notes, and snippets.

@Kroc
Kroc / gist:3551351
Created August 31, 2012 10:41
Kroc's Transliteration Method
//safeTransliterate v3, copyright (cc-by 3.0) Kroc Camen <camendesign.com>
//generate a safe (a-z0-9_) string, for use as filenames or URLs, from an arbitrary string
function safeTransliterate ($text) {
//if available, this function uses PHP5.4's transliterate, which is capable of converting arabic, hebrew, greek,
//chinese, japanese and more into ASCII! however, we use our manual (and crude) fallback *first* instead because
//we will take the liberty of transliterating some things into more readable ASCII-friendly forms,
//e.g. "100℃" > "100degc" instead of "100oc"
/* manual transliteration list:
-------------------------------------------------------------------------------------------------------------- */