--- elf.module.dev	2010-05-12 14:45:40.000000000 +0200
+++ elf.module	2010-05-12 14:48:13.000000000 +0200
@@ -121,8 +121,9 @@ function elf_form_settings_validate(arra
  */
 function elf_replace($text, stdClass $filter) {
   $doc = new DOMDocument;
-  // We are using a wrapper to prevent tags from being added automatically.
-  $text = '<div>' . $text . '</div>';
+  // We are using a wrapper to prevent tags from being added automatically 
+  // and to set encoding of the text to UTF-8
+  $text = '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><div>' . $text . '</div>';
   $doc->loadHTML($text);
   $as = $doc->getElementsByTagName('a');
   foreach ($as as $a) {
