You are here

function notify_entities_to_utf8 in Notify 5.2

Same name and namespace in other branches
  1. 5 notify.module \notify_entities_to_utf8()
1 call to notify_entities_to_utf8()
_notify_content in ./notify.module
Formatting of outgoing mail, taken from mail.inc, part of project.module

File

./notify.module, line 489

Code

function notify_entities_to_utf8($text) {
  static $table;

  // We store named entities in a table for quick processing.
  if (!isset($table)) {

    // Get all named HTML entities.
    $table = array_flip(get_html_translation_table(HTML_ENTITIES));

    // PHP gives us Windows-1252/ISO-8859-1 data, we need UTF-8.
    $table = array_map('utf8_encode', $table);
  }
  $text = strtr($text, $table);

  // Any remaining entities are numerical. Use a regexp to replace them.
  return preg_replace('/&#(x?)([A-Za-z0-9]+);/e', '_notify_entity_to_utf8("$1", "$2")', $text);
}