You are here

function transliteration_clean_filename in Transliteration 5

Same name and namespace in other branches
  1. 5.2 transliteration.inc \transliteration_clean_filename()
  2. 6.3 transliteration.module \transliteration_clean_filename()
  3. 6 transliteration.inc \transliteration_clean_filename()
  4. 6.2 transliteration.inc \transliteration_clean_filename()
  5. 7.3 transliteration.module \transliteration_clean_filename()

Sanitize a file name.

Transliterates the file name and removes all problematic characters.

Parameters

string $filename: A file name.

Return value

string Cleaned file name.

1 call to transliteration_clean_filename()
transliteration_menu in ./transliteration.module
Implementation of hook_menu().

File

./transliteration.inc, line 13

Code

function transliteration_clean_filename($filename) {

  // Trim any leading/trailing dots.
  $filename = trim($filename, '.');

  // Transliterate to ASCII.
  $filename = _transliteration_process($filename, '');

  // Replace whitespace.
  $filename = str_replace(' ', '_', $filename);

  // Remove any remaining non-safe characters.
  $filename = preg_replace('/[^0-9A-Za-z_.-]/', '', $filename);
  return $filename;
}