views:

81

answers:

2

Hi guys, 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 :(

+1  A: 

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.

VolkerK
Uh How do I do that I mean send it as plain utf 8
Ali
How do you send the string client->server (code)?
VolkerK
+2  A: 

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().

jeroen
Neither utf8-decode() nor htmlentities() translate a %u... sequence.
VolkerK
As I read the question, the original string does not contain a %u... sequence but characters with accents.
jeroen
The problem is that the characters ones they reach the php script are changed from accentuated characters into these funny %u sequences...
Ali
I, I misunderstood, I thought it was the other way around...
jeroen