Search code examples
phpapachewampurl-encodingutf

Character encoding seems to work on a MAMP server but not on a WAMP server


I've been working on a web application that should be able to accept tags and search queries in multiple languages. That's not asking too much, is it?

Now, on my development MAMP server everything is great. I add multilingual tags, search in any language I want etc.

On the other hand, on the production WAMP server, multilingual characters give trouble. And not even all the time, just some of the time, or some of the characters, I'm not sure yet.

What happens is that they get extra characters and then their URL decoding isn't proper.

Both Environments use PHP 5, MySQL and Apache.

My guess is that I got a setting wrong somewhere.

Any Ideas?

  • update: I'm now sure it's particular letters (the hebrew ל,מ א for example)

  • update: easily reproducible: always the same letters get wrong encoding.

  • content type is text/html; charset=utf-8

Also, I've pinpointed it a bit further:
I use the search string: ליבני
On the results page I see this:

  • In the address bar the search phrase is correct, properly url-encoded.
  • In the HTML itself I see the string "�_יבני" which is "%D7_%D7%99%D7%91%D7%A0%D7%99" which means the ל has been encoded to "%D7_" instead of "%D7%9C" as it should have.

I don't really know where to go further.
Any ideas? anyone?


Solution

  • It turns out the problem is somewhere within PHP's parse_url(). I guess that in some versions, on some platforms, parse_url() doesn't handle UTF characters correctly. It was spotted on windows at least one more time.

    I was able to workaround it for now.

    Thanks for everybody's time and attention, Omer.