You are here

function _transliteration_replace in Transliteration 6.3

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

Replace a Unicode character using the transliteration database.

Parameters

$ord: An ordinal Unicode character code.

$unknown: Replacement string for characters that do not have a suitable ASCII equivalent.

$langcode: Optional ISO 639 language code that denotes the language of the input and is used to apply language-specific variations. Defaults to the current display language.

Return value

ASCII replacement character.

1 call to _transliteration_replace()
transliteration_process in ./transliteration.inc
Transliterate UTF-8 encoded text to US-ASCII.

File

./transliteration.inc, line 177
Transliteration processing functions.

Code

function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
  static $map = array();
  if (!isset($langcode)) {
    global $language;
    $langcode = $language->language;
  }
  $bank = $ord >> 8;
  if (!isset($map[$bank][$langcode])) {
    $file = drupal_get_path('module', 'transliteration') . '/data/' . sprintf('x%02x', $bank) . '.php';
    if (file_exists($file)) {
      include $file;
      if ($langcode != 'en' && isset($variant[$langcode])) {

        // Merge in language specific mappings.
        $map[$bank][$langcode] = $variant[$langcode] + $base;
      }
      else {
        $map[$bank][$langcode] = $base;
      }
    }
    else {
      $map[$bank][$langcode] = array();
    }
  }
  $ord = $ord & 255;
  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
}