title: MySQL Replace with Char Function
body: <p>I try to create a MySQL function to parse a given string into a version I can use in an URL. So I have to eliminate some special characters and I try to do it with a loop to keep the code simple and to not have to specify any character.</p>
  
  <p>My current code is:</p>
  
  <pre><code>DECLARE parsedString VARCHAR(255);
  
  # convert to low chars
  SET parsedString    =   CONVERT(paramString USING latin1);
  SET parsedString    =   LOWER(parsedString);
  
  # replace chars with A
  SET @x = 223;
  
  charReplaceA: WHILE @x &lt;= 229 DO
      SET @x = @x + 1;
  
      SET parsedString    =   REPLACE (parsedString, CHAR(@x USING ASCII), 'a');
  END WHILE charReplaceA;
  
  # convert to utf8 and return
  RETURN CONVERT(parsedString USING utf8);
  </code></pre>
  
  <p>If I try to use my code it doesn't work. Somehow it doesn't recognize the CHAR(@x USING ASCII) part.</p>
  
  <pre><code>SELECT urlParser('aäeucn');
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>aäeucn
  </code></pre>
  
  <p>If I change my code to</p>
  
  <pre><code>SET parsedString    =   REPLACE (parsedString, 'ä', 'a');
  </code></pre>
  
  <p>it somehow works and returns</p>
  
  <pre><code>aaeucn
  </code></pre>
  
  <p>Does anyone have any idea how to use REPLACE() with CHAR()? I don't want to specify any possible character.</p>