So I'm uploading a csv file. One of the column have a single quote.
145 Test St'
The array is
(
[0] => 2
[1] => 20
[2] => 145 Test St�
[3] => Test City
[4] => 1455
[5] => 919749797
)
As you can see. Instead of single quote ( ' ), it becomes �.
From here, I use htmlspecialchars($row), which gives the result.
(
[0] => 2
[1] => 20
[2] =>
[3] => Test City
[4] => 1455
[5] => 919749797
)
First question, why ( ' ) becomes ( � ) ?
Second question, why after using htmlspecialchars(), the value disappear?
Third question, How can I retain the ( ' ) ?
Thanks for those who can answer.
EDIT:
$row = array_map('str_getcsv', file($_FILES['file']['tmp_name']));
$csv = Array();
$head = $row[0];
$col = count($row[0]);
unset($row[0]);
pre($row[1]);
$row[1] = array_map('htmlentities', $row[1]);
pre($row[1]);
EDIT:
pre() is a function I created that works like
<pre></pre>.
EDIT:
I've look at the CSV file using file --mime at the terminal. It's charset is unknown 8-bit. I convert the CSV file to UTF-8 by doing a save as. After that I manage to upload the CSV file successfully. The problem is on the encoding of the CSV file.
Is it possible to convert the file into UTF-8?