Jump to content

Invalid byte 2 of 3-byte UTF-8 sequence


msimonds

Recommended Posts

I am having an issue when I am trying to parse a .csv file and process it via SOAP to Salesforce.com using their API

 

This is the first time this has happened and I need some guidance on what I can do to correct this

 

I am reading the file, each record is an array:

 

[DIST_NAME] => company
[PARENT_BRANCH] => H387
[PROJECT_NAME] => Bussplex
[END_PRODUCT] => Vehicle instrumentation
[CUSTOMERNAME] => Customer
[RECORD_CREATION_DATE] => 4/22/2008
[bOARD_NAME] => Main board
[PROTOTYPE_DATE] => 3/7/2008
[PRODUCTION_DATE] => 6/6/2008
[bOARDSPERYEAR] => 500
[bOARD_DESIGN_PHASE] => Prototype
[bOARD_FUNCTION] => CPU
[REG_ID] => 999999999
[REG_NO] => 
[sTATUS] => Pending
[PENDING_DATE] => 3/28/2008 8:56
[WIN_DATE] => 
[REG_PART_FAMILY] => 13442
[REG_PART_SUPPLIER_PART_NO] => 13442EASA+
[REG_PART_PRICE] => 2.04
[REG_PART_QTY_PER_BOM] => 9
[AM_NAME] => João Carlos Boaventura
[FAE_NAME] => João Carlos Boaventura
[CUSTOMERENGINEER] => João Carlos Boaventura
[OFFICE_PHONE] => 555-1212
[email] => [email protected]
[EXT_COMMENTS] => 
[APPR_REJ_REASON] => 
[RENEW_DATE] => 

 

 

Every file processed fine until we started receiving text with foreign characters:

 

João

 

 

 

I know that I could just use strtr to correct each value of the array, one by one,

 

 

What I am looking to do is clean the whole entire record/array, so if this comes in from the .csv file:

 

[AM_NAME] => João Carlos Boaventura
[FAE_NAME] => João Carlos Boaventura
[CUSTOMERENGINEER] => João Carlos Boaventura

 

I can replace it with

 

[AM_NAME] => Joao Carlos Boaventura
[FAE_NAME] => Joao Carlos Boaventura
[CUSTOMERENGINEER] => Joao Carlos Boaventura

 

 

I tried this

 


array_map('translate', $data);

function translate($string) 
{

$search = 'ãäåö';
$replace = 'aaao';
$string = strtr($string, $search, $replace);

return $string;
}

 

but of coarse it is not working

 

Does anyone have some function or some idea of what I need to do

 

Hope this makes sense

 

 

 

~Mike

Link to comment
https://forums.phpfreaks.com/topic/102774-invalid-byte-2-of-3-byte-utf-8-sequence/
Share on other sites

What you need to use is not strstr(), but str_replace();

 

Also, $search and $replace have to be in array format.

 

 

 

Could you give me an example of this

 

@effigy, sorry I am not up to speed on what is and what is not utf8, I am just posting the error that I am receiving from Salesforce's API and if I correct this one record by replacing "ã"  with "a" and process the record again, it inserts perfectly.  So it has to be that text that is causing the problem

 

Thanks,

~Mike

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.