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 Quote Link to comment 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, Quote Link to comment Share on other sites More sharing options...
l4nc3r Posted March 9, 2008 Author Share Posted March 9, 2008 Ah, thanks! That made it work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.