title: Special Characters & URL Rewriting
body: <p>I am currently working on an application that pulls JSON data from the blizzard community API and parses it with PHP. Everything works okay until I come to a character with a special character in their name. </p>
  
  <p>In order to pull the characters data I need to know their characters name and realm that they are on.</p>
  
  <p>I have the name and realm being passed through the URL to the character page, and from there using that information to pull the character data.</p>
  
  <p>At this point my URLs are like so:</p>
  
  <pre><code> http://localhost/guildtree/characters.php?realm=argent-dawn&amp;name=Ankzu
  </code></pre>
  
  <p>At this point if I try to pull data for a character with an accent I get re-directed to my error page because it is not a valid character.</p>
  
  <p>It wasn't until I started the URL rewriting that I discovered my problem. I am being re-directed to my error page because somewhere along the line the special characters are being substituted for some really wonky characters.</p>
  
  <p>With my new rewritten URLs the follow works:</p>
  
  <pre><code> http://localhost/guildtree/argent-dawn/ankzu
  </code></pre>
  
  <p>However, a character with a special character in their name results in an error message.</p>
  
  <pre><code> http://localhost/guildtree/argent-dawn/notúk
  </code></pre>
  
  <p>Results in the following error message:</p>
  
  <p>"Not Found</p>
  
  <p>The requested URL /guildtree/argent-dawn/notÃºk was not found on this server."</p>
  
  <p>As you can see the ú is being substituted for Ãº, but when I copy and paste the URL the ú appears as %C3%BA</p>
  
  <p>It is my understanding that the reason why the ú is appearing as Ãº is because the two byte unicode ú is being squished into two one byte ASCII characters resulting in the Ãº being displayed.</p>
  
  <p>I have ensured that all my pages have the following in the header:</p>
  
  <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  </code></pre>
  
  <p>In order for my application to work properly I need those special characters to display properly, so I need the ú to actually display as ú, not appear as ú but actually be Ãº or %C3%BA.</p>
  
  <p>The characters name is being pulled from the URL simply as:</p>
  
  <pre><code>$charName = $_GET['name'];
  </code></pre>
  
  <p>Is it possible to encode $charName to display the special characters properly?</p>
  
  <p>I have tried everything I can think of and have searched on Google but nothing has worked.</p>
  
  <p>Also, because I am using URL rewriting what would the rewrite rule be to allow for these special characters?</p>
  
  <p>Here is my current rewrite rule:</p>
  
  <pre><code> RewriteRule ^([a-zA-Z0-9_'-]+)/([a-zA-Z]+)$        characters.php?realm=$1&amp;name=$2     [NC]
  </code></pre>
  
  <p>I'm aware that ([a-zA-Z]+) does not allow at all for special characters, I have currently been working on getting the special characters to display properly. If I use ([a-zA-Z\Ãº]+) it will work and display the page as it needs to be displayed. Adding the \Ãº to the rule seems like a very poor way to do this and does not always work while using the corresponding character for the accented characters.</p>
  
  <p>Any help would be greatly appreciated. If you require any more information please ask.</p>
  
  <p>Edit:</p>
  
  <p>Changing my rewrite rule to the below allows for the information to be pulled fine, but creates a redirect loop for my CSS.</p>
  
  <pre><code> RewriteRule ^([a-zA-Z0-9_'-]+)/([^/]+)$        characters.php?realm=$1&amp;name=$2 [NC]
  </code></pre>
  
  <p>For example my CSS is being redirected to</p>
  
  <pre><code>http://localhost/guildtree/css/error
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>http://localhost/guildtree/css/style2.css
  </code></pre>
  
  <p>Update:</p>
  
  <p>Through a few simple tests:</p>
  
  <pre><code>$charName = $_GET['name'];
  $charNameTEST = utf8_encode($charName);
  </code></pre>
  
  <p>Will make the change, but when I apply this to my page it still comes up saying:</p>
  
  <p>"Not Found</p>
  
  <p>The requested URL /guildtree/argent-dawn/notÃºk was not found on this server."</p>
  
  <p>I think the main issue now is with the URL redirecting, because the JSON data can be parsed perfectly fine when it has the accented characters. I just don't understand why it keeps showing me that it is on guildtree/argent-dawn/notúk in the browser bar, but keeps trying to pull up /guildtree/argent-dawn/notÃºk.</p>