Comments Blog About Development Research Sites

Ajax and UTF-8
Disaster is near...

Dec 12, 2007
Today we came across quite an interesting problem while loading data into our database. Or more exactly, the people entering the data encountered the problem, didn't know what to do, called us and eventually were able to convey it.

We use a simple AJAX library for most backoffice stuff, SAJAX, which tends to work quite nicely most of the time. Problems arose when weird UTF-8 characters were incoded: before they were send to the server these got escaped by javascript's escape function. Rightfully so of course, but it meant we'd got weird escaped entities in our database, which is kind of a bitch since PHP does not have an equivalent unescape function.

Luckily we weren't the first to encounter that problem: Janci on wrote a neat workaround that's basicly the PHP equivalent of JS' unescape!

Of course, to fix the existing data I just let the server run about 1200 queries to update each record =]

FragFrog out!

New comment

Your name: