--- headinganchors.module	2008-12-31 17:08:36.000000000 -0500
+++ headinganchors2.module	2009-03-18 20:43:05.000000000 -0400
@@ -74,6 +74,9 @@ function headinganchors_filter($op, $del
       preg_match_all("/<h([1-6])([^>]*)>(.*?)<\/h[1-6]>/is", $text, $matches, PREG_PATTERN_ORDER);
       $count = 0;
       $anchors = array();
+      // Parsing i18n-ascii.txt (thanks to pathauto for this file)
+      // for further accents transliteration (e.g. é=>e).
+      $translations = parse_ini_file(drupal_get_path('module', 'tableofcontents') . '/i18n-ascii.txt');
       foreach ($matches[0] as $match) {
 
         // get level and heading
@@ -91,9 +94,13 @@ function headinganchors_filter($op, $del
           // if no id found, create one
         }
         else {
-          // sanitize ID text & remove leading digits (invalid on IDs)
+          // Sanitize ID text & remove leading digits (invalid on IDs).
           $anchor = preg_replace("/&amp;/", "", strip_tags($matches[3][$count]));
-          $anchor = preg_replace("/[^A-Za-z0-9]/", "", $anchor);
+          $anchor = strtr($anchor, $translations);
+          $anchor = preg_replace("/ +/", "-", $anchor);
+          // This regex is defined in the XHTML standard at
+          // http://www.w3.org/TR/xhtml1/#C_8.
+          $anchor = preg_replace("/[^A-Za-z0-9:_.-]/", "", $anchor);
           $anchor = preg_replace("/^[0-9]+/", "", $anchor);
         }
 
