function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sgeninsgenin 

Problem with French characters

Hello,
I try to create a lead using the API. Here is my code :

$FIELDS=array(
'type' => 'lead',
'FirstName' => $firstname,
'LastName' => $lastname,
'Title' => $title,
'Company' => $company,
'Website' => $url,
'Email' => $email,
'Phone' => $phone,
'Street' => $street,
'PostalCode' => $zip,
'City' => $city,
'Country' => $country,
'LeadSource' => $know_us,
'Recevoir_les_Infos_modifie_le__c',$info_date,
'Recevoir_les_Infos_par_email__c',$info_str,
'Recevoir_la_Newsletter__c',$news_str,
'Recevoir_la_Newsletter_modifie_le__c',$nl_date,
'Origine_du_contact__c',$source,
'Description',$description);

$result=$client->create($FIELDS);

As soon as I have accentuated characters in some fields (FirstName, LastName, ...), I get the following error :

soap_fault Object ( [error_message_prefix] => [mode] => 1 [level] => 1024 [code] => soapenv:Server.userException [message] => java.io.UTFDataFormatException: Invalid byte 2 of 3-byte UTF-8 sequence. [userinfo] => [backtrace] => [callback] => )

java.io.UTFDataFormatException: Invalid byte 2 of 3-byte UTF-8 sequence.

Do you know what I shall do to have it working?

Thanks
Stéphane
HarryBHarryB

Hi!

Try to UTF8-Encode all strings that could contain french/accentuated chars, like

$FIELDS=array(
'type' => 'lead',
'FirstName' => utf8_encode ($firstname),
'LastName' => utf8_encode ($lastname),
...

Maybe its a good idea to UTF8-Encode ALL strings that you put into SF. That way you don't have this problem again.

For php UTF8-Encoding see:

http://de2.php.net/manual/en/function.utf8-encode.php

Cheers,

Harry