Wednesday, August 06, 2008

XML-RPC for PHP Library + UTF-8 = love

If you have problems with the XML-RPC for PHP library (http://phpxmlrpc.sourceforge.net/) and UTF-8, please be advised that in xmlrpc.inc you will find the following lines:

// The charset encoding used by the server for received messages and
// by the client for received responses when received charset cannot be determined
// or is not supported
$GLOBALS['xmlrpc_defencoding']='UTF-8';

// The encoding used internally by PHP.
// String values received as xml will be converted to this, and php strings will be converted to xml
// as if having been coded with this
GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';

As you can see, internally everything seems to be converted to ISO-8859-1, no idea why. If you change this to
$GLOBALS['xmlrpc_internalencoding']='UTF-8';
you will be able to use UTF-8 correctly with the library.

No comments: