You are here

transliteration.module in Transliteration 6

Provides transliteration for UTF-8 text input and sanitzes file names.

Uses data from the Text::Unidecode Perl library.

File

transliteration.module
View source
<?php

/**
 * @file
 * Provides transliteration for UTF-8 text input and sanitzes file names.
 *
 * Uses data from the Text::Unidecode Perl library.
 * @see http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm
 */

/**
 * Transliterate UTF-8 input to plain ASCII.
 *
 * @param string $input
 *   UTF-8 text input.
 * @param string $unknown
 *   Replacement for unknown or illegal characters.
 * @return string
 *   Plain ASCII output.
 */
function transliteration_get($input, $unknown = '?') {
  require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
  return _transliteration_process($input, $unknown);
}

/**
 * Implementation of hook_init().
 *
 * Transliterate and clean the names of files currently being uploaded.
 */
function transliteration_init() {
  if (!empty($_FILES['files'])) {
    require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
    foreach ($_FILES['files']['name'] as $field => $filename) {
      $_FILES['files']['name'][$field] = transliteration_clean_filename($filename);
    }
  }
}

Functions

Namesort descending Description
transliteration_get Transliterate UTF-8 input to plain ASCII.
transliteration_init Implementation of hook_init().