title: Replacing umlauts in JS
body: <p>I am comparing strings and have to replace umlauts in JS, but it seems JS does not recognize the umlauts in the strings. The text comes from the database and in the browser the umlauts do show fine.</p>
  
  <pre><code>function replaceUmlauts(string)
  {
      value = string.toLowerCase();
      value = value.replace(/ä/g, 'ae');
      value = value.replace(/ö/g, 'oe');
      value = value.replace(/ü/g, 'ue');
      return value;
  }
  </code></pre>
  
  <p>As search patterns I tried:</p>
  
  <ul>
  <li>"ä", "ö", "ü"</li>
  <li>/ä/, /ö/, /ü/</li>
  <li>"<code>&amp;auml;</code>", "<code>&amp;ouml;</code>", "<code>&amp;uuml;</code>" (well total despair ;-))</li>
  </ul>
  
  <p>To be sure, that it is not a matter with the replace function I tried indexOf:</p>
  
  <pre><code>console.log(value.indexOf('ä'));
  </code></pre>
  
  <p>But the output with all patterns is: <code>-1</code></p>
  
  <p>So I guess it is some kind of a problem with encoding, but as I said on the page the umlauts do just look fine.</p>
  
  <p>Any ideas? This seems so simple...</p>
  
  <p>EDIT:
  Even if I found my answer, the problem was not really solved "at the root" (the encoding).
  This is my page encoding:</p>
  
  <pre><code>&lt;meta content="text/html; charset=UTF-8" http-equiv="Content-Type"&gt;
  </code></pre>
  
  <p>The database has: utf8_general_ci</p>
  
  <p>Seems totally alright to me.</p>