jQuery autocomplete special character (Norwegian) problems
<p>I'm using jQuery's autocomplete function on my Norwegian site. When typing in the Norwegian characters æ, ø and å, the autocomplete function suggests words with the respective character, but not words starting with the respective character. It seems like I've to manage to character encode Norwegian characters in the middle of the words, but not characters starting with it.</p>

<p>I'm using a PHP script with my own function for encoding Norwegian characters to UTF-8 and generating the autocomplete list.</p>

<p>This is really frustrating!</p>

<p>Code:</p>

<p>PHP code:</p>

<pre><code>$q = strtolower($_REQUEST["q"]);
if (!$q) return;

function rewrite($string){

 $to = array('%E6','%F8','%E5','%F6','%EB','%E4','%C6','%D8','%C5','%C4','%D6','%CB', '%FC', '+', ' ');
 $from = array('æ', 'ø', 'å', 'ä', 'ö', 'ë', 'æ', 'ø', 'å', 'ä', 'ö', 'ë', '-', '-');

 $string = str_replace($from, $to, $string);

 return $string;
}
</code></pre>

<p><code>$items</code> is an array containg suggestion-words.</p>

<pre><code>foreach ($items as $key=&gt;$value) {
  if (strpos(strtolower(rewrite($key)), $q) !== false) {
    echo utf8_encode($key)."\n";
  }
}
</code></pre>

<p>jQuery code:</p>

<pre><code>$(document).ready(function(){
$("#autocomplete").autocomplete("/search_words.php", {
        position: 'after',
        selectFirst: false,
        minChars: 3,
        width: 240,
        cacheLength: 100,
        delay: 0
        }
    )
}
);
</code></pre>
