title: jQuery "Uncaught URIError: URI malformed" Error with Emoticons
body: <p>I'm using the following JavaScript code that works with pretty much everything but emotions. I keep receiving the following error.</p>
  
  <blockquote>
    <p>Uncaught URIError: URI malformed</p>
  </blockquote>
  
  <p>If I change the value of <code>a_msg</code> from <code>""</code> to something else, it works! Note that in practice I'm collecting these values from a <code>textarea</code>, so I don't really have control over the encoding of the characters entered there, as it is often dependent on the (virtual) keyboards used.</p>
  
  <pre><code>var a_name = "my name";
  var a_msg = "";
  $.post("myphp.php", { name: a_name, msg: a_msg });
  </code></pre>
  
  <p>My PHP code is also straightforward.</p>
  
  <pre><code>$name = $_POST["name"];
  $msg = $_POST["msg"];
  </code></pre>
  
  <p>The Webpage uses UTF-8 charset.</p>
  
  <pre><code>&lt;meta charset="UTF-8"&gt;
  </code></pre>
  
  <p>So far I have tried (based on similar questions posted on the forum),</p>
  
  <ol>
  <li><code>encodeURIt()</code>, <code>encodeURIComponent()``decodeURIComponent()</code> and <code>decodeURI()</code>in the JavaScript,</li>
  <li><code>escape()</code> works if the original text does not contain "%",</li>
  <li><code>utf8_encode()</code> in the PHP, and</li>
  <li><code>&lt;form accept-charset="ISO-8859-1"&gt;</code> in the HTML.</li>
  </ol>
  
  <p>But no luck or whatsoever.</p>
  
  <p>What am I doing wrong? How can I fix this? Thanks in advance.</p>