UTF-8 issue?

Topics: Developer Forum, User Forum
Jun 3, 2011 at 10:04 PM

Hi,

I'm having problems with the reader translating special characters in a strange manner. I'd imagine it would happen with most extended/special characters but the surname in my query which is causing issues is Márquez. The source file is an XLXS file and I can't find out what version of PHPExcel I'm using but the files are dated mid-February and it it ceratinly this year when I updated.

Anyway, it's displaying fine in Excel and when used with html_entity_decode($v, ENT_QUOTES) the value in my database is Márquez. However, the value that is coming out of the PHPExcel reader is Márquez.

I am happy to give more details if required but that might be enough if it's something simple that I'm overlooking. That wouldn't surprise me.

Thanks,

WorldOfWires


Coordinator
Jun 3, 2011 at 10:25 PM

I don't understand what you're doing here; but an xlsx file should hold all strings as UTF-8 values, and PHPExcel holds all strings that are read from an xlsx file internally as UTF-8 values, so there is no charset conversion/translation involved (so no scope for any conversion/translation problems). If you display the data read from the worksheet to a UTF-8 HTML page, it should display correctly.

Can you explain where your database comes into this?

Jun 3, 2011 at 10:52 PM
Edited Jun 3, 2011 at 10:58 PM

Hi,

Sorry for confusing things. I'm comparing values stored in my databases to cells read from a xlsx file. I convert the values to HTML entities before storing so the value from the Excel file that I'll be comparing it against is Márquez. It's currently coming through as Márquez and I can't see why. 

I'll try just plain rendering the value onscreen and see what it looks like. In the meantime, this is all I'm doing to get the reader going...

 

 

$objReader = PHPExcel_IOFactory::createReader($ftt);
$objPHPExcel = $objReader->load($arrs['full_path']);
				
foreach($objPHPExcel->getWorksheetIterator() as $worksheet) {
	$tit=$worksheet->getTitle();
        etc
     
        $val=$worksheet->getCell($y2.$x)->getValue();
}

$ftt is a variable in this instance containing Excel2007.

Coordinator
Jun 4, 2011 at 9:04 AM

If you want to use html_entity_decode() to see the values, you might want to specify the charset as UTF-8 rather than relying on the default

Jun 9, 2011 at 12:36 PM
MarkBaker wrote:

If you want to use html_entity_decode() to see the values, you might want to specify the charset as UTF-8 rather than relying on the default

Hi Mark,

Very sorry about the delay in responding, I've been travelling for a few days. Where would I specify the UTF-8 charset? In PHPExcel or just the PHP script? Sorry for being a bit dumb.

Thanks.