0

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:[email protected]/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?

5
  • 1
    What's the source code's encoding, and did you use use utf8;?
    – ikegami
    Jun 16, 2014 at 13:35
  • File is written using Notepad++ and I used UTF-8 without BOM encoding!
    – MrD
    Jun 16, 2014 at 13:36
  • 1
    Did you use use utf8;? If not, you don't actually have a "Č" in the source code.
    – ikegami
    Jun 16, 2014 at 13:36
  • I used UTF-8 encoding!
    – MrD
    Jun 16, 2014 at 13:52
  • So you've said, but that doesn't answer my question. Did you tell Perl you used UTF-8 by using use utf8;?
    – ikegami
    Jun 16, 2014 at 14:20

1 Answer 1

5

In xmlrpc.inc replace this

$GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';

with this

$GLOBALS['xmlrpc_internalencoding']='UTF-8';
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.