l4nc3r Posted March 9, 2008 Share Posted March 9, 2008 I'm creating a program that will parse an uploaded csv file, but I keep getting these strange characters within the data. If I re-save the file in MS Excel, it works fine, but I need the originals to work. The only differences between the two are the " it inserts before/after each row and the attributes property of the new file (in right click > properties > details) is just A, where in the original it's AN. What does that mean? Here's the code: ... $report_resource = fopen($_FILES['report']['tmp_name'], 'r'); echo fread($report_resource,filesize($_FILES['report']['tmp_name'])); while ($report_data = fgetcsv($report_resource, '', ',')) { ... } ... Which outputs: e�x�t�b�o�x�2�,�t�e�x�t�b�o�x�3�,�X�A�_�T�r�a�n�A�m�t�_�1�,�X�A�_�R�S�B�a�l�a�n�c�e�_�1�,�X�A�_�R�S�P�o�i�n�t�s�_�1�, It has the data there, it's just garbled by the ? characters. What's happening? Any help much appreciated Link to comment https://forums.phpfreaks.com/topic/95230-fread-showing-strange-characters-in-data/ Share on other sites More sharing options...
Barand Posted March 9, 2008 Share Posted March 9, 2008 UTF encoded (2-byte chars) <?php $str = "e�x�t�b�o�x�2�,�t�e�x�t�b�o�x�3�,�X�A�_�T�r�a�n�A�m�t�_�1�,�X�A�_�R�S�B�a�l�a�n�c�e�_�1�,�X�A�_�R�S�P�o�i�n�t�s�_�1�,"; $k = strlen($str); $res = ''; for ($i=0; $i<$k; $i+=2) $res .= $str[$i]; echo $res; ?> --> extbox2,textbox3,XA_TranAmt_1,XA_RSBalance_1,XA_RSPoints_1, Link to comment https://forums.phpfreaks.com/topic/95230-fread-showing-strange-characters-in-data/#findComment-487800 Share on other sites More sharing options...
l4nc3r Posted March 9, 2008 Author Share Posted March 9, 2008 Ah, thanks! That made it work Link to comment https://forums.phpfreaks.com/topic/95230-fread-showing-strange-characters-in-data/#findComment-487851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.