0

welcome

im trying to read csv file in php my file contain Arabic data

what charset must be use to show correct result ??

echo iconv("???????",'UTF-8',$data[$c]."\0");  
Ala'a Hamda
  • 31
  • 1
  • 9

2 Answers2

1

Arabic is usually encoded as ISO8859-6, so try:

echo iconv("ISO-8859-6",'UTF-8',$data[$c]."\0");  

Check out encoding check and Determine and change file character encoding for information on how to find which encoding.

As well, you have to make sure that you use UTF-8 everywhere, and that PHP is configure to handle UTF-8.

In the html, add the meta-tag:

<meta charset="utf-8" />

And save it in UTF-8 format. here is how to do that in notepad++.

Enable UTF-8 in the php.ini:

default_charset = "utf-8"

For a full manual check Handling Unicode Front To Back In A Web App

Community
  • 1
  • 1
Kuf
  • 17,318
  • 6
  • 67
  • 91
0

If its not already UTF-8 then it will most likely being iso 8859-6.

But you can't be sure. To get sure you'll have to know the source encoding as it cannot be detected reliable.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266