weblog

character encoding in Ajax request

The answer is no secret, you always have to encode your parameters according to the char set your working on. In Javascript byte encoding is is a pain when you are trying to enconde every character but luckly server side encoding is really easy in PHP you can use mb_convert_encoding wich is a powerful function that works like a charm, there’s also the mb_detect_encoding wich will return the current encoding. In rails you can use iconv or add a library wich will make things easier.

In the end don’t get angry if your accented characters don’t parse correctly by your Ajax request, instead look for a way to encode your strings of characters properly.

Post your opinion:

destitute
destitute
destitute
destitute