Okay, so i'm working on some plugins for some of our clients, that basically takes data from their MySQL database, and sends it to us via. XML generated with SimpleXML.
Now, when we receive the XML-file we run it through a script putting their data into our database, and here comes the problem.
When we put the clients data into our database, in some cases some of the characters are converted to chinese letters. (We use UTF-8)
Now i figure this could be resolved if i had a way to determine the encoding of the clients database, and convert to UTF8 and give the XML-file the header <?xml version="1.0" encoding="UTF-8" ?>
. My problem is to detect the encoding given to me from the clients database, and converting it to UTF-8 properly.
I've had a look at php's mb_detect_encoding()
and mb_convert_encoding
, but are unsure of how common the "Multibyte String" extension is, and i would like to keep the compatibility of the plugin as high as possible.
Any ideas as to how i do this best? Let me know if you need more information.
EDIT: Okay, use of mysql_set_charset('UTF8')
and setting SimpleXML to <?xml version="1.0" encoding="UTF-8" ?><xml/>
does the job, thanks for the help.
Accepting daids answer since he was the one to lead me to this solution.