问题
I'm using XMLRPC client to call Adestra API services. Currently I'm having problems inserting Bosnian letters č, ć, ž, đ, š.
I configured my XMLRPC client to work with UTF-8, but still having problems. Here my code sample:
//******* LOGIN DATA*******/
$account = 'account';
$username = 'username';
$password = 'password';
$adestraCoreTable=1;
/**INITIALIZE API*****/
require_once('xmlrpc.inc');//First inlcude XMLRPC client library
//Calling Adestra API with our credentials
$xmlrpc= new xmlrpc_client("http://$account.$username:$password@new.adestra.com/api/xmlrpc");
$xmlrpc->setDebug(0);
$xmlrpc->request_charset_encoding="UTF-8";
$msg = new xmlrpcmsg(
"contact.search",
array(
//Set user id
new xmlrpcval($adestraCoreTable, "int"),
new xmlrpcval(
array(
"firstName"=> new xmlrpcval("Čokolada", "string"),
),"struct"
)
)
);
$response = $xmlrpc->send($msg);//Send request, and get the response
The rest of the code is parsing the $response which is not our main interest here.
As you can see, the firstName
is set to Čokolada
, but when I check it in Adestra, I get the value Äokolada
. Obviously, there is problem in encoding.
Anyone can help?
回答1:
In xmlrpc.inc replace this
$GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';
with this
$GLOBALS['xmlrpc_internalencoding']='UTF-8';
来源:https://stackoverflow.com/questions/24244996/how-to-set-utf-8-encoding-with-xmlrpc-client-library