Question

I've run into issues here I notice that some accentuated characters if I try to pass them as value sin an ajax call they end up all funny LIke for example:

Adana Şakirpaşa

turns into

Adana %u015Eakirpa%u015Fa

WHats wrong here :(

EDIT==================

The problem is that once the characters are recieved by my php script on the backend they are all messed up by then! What should I do :(

Was it helpful?

Solution

I have run into the same problem and have used utf8_encode() on the data in the php script that was called using ajax to solve it. I think you can also use htmlentities().

OTHER TIPS

Java/ECMAscript parses \uxxxxxx sequences but not %u... in the source text.
see http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf

You can convert the transport form with the javascript function unescape()
e.g.

<html>
  <head><title>...</title>
    </script>
  </head>
  <body>
    <p id="output"></p>
    <script type="text/javascript">
      var x = 'Adana %u015Eakirpa%u015Fa';
      document.getElementById("output").innerHTML = unescape(x);
    </script>
  </body>
</html>

shows

Adana Şakirpaşa

But you might consider to store and send it as "plain" utf-8 characters server-side.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top