0

i get rows from .csv file. what i am trying to do is to encode the text that i get in utf8 format, buy actually i get just gibberish.

my code:

    <?php

header('Content-Type: text/html; charset=utf-8');



$row = 1;
if (($handle = fopen("newsletter.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    echo mb_convert_encoding($data[5],"utf-8");
    echo "<HR>";
    }
    fclose($handle);
}

?>

i was looking in: http://il1.php.net/mb_convert_encoding

is there a possible way to print the wanted strings in Hebrew?

the problem that mb_convert_encoding doesn't supports windows-1255...

i was also in: iconv http://php.net/manual/en/function.iconv.php

somebody there posted how to convert it but it didn't work to me:

preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$temp);

thanks!!

  • What's the encoding of the input file? What does the gibberish output look like? Why would you convert it to something else than UTF-8? – tripleee Aug 29 '13 at 17:25
  • i don't know whats the encoding of the input... it looks like 2 àì: ùí îìà: éåâá ì. – user2730162 Aug 29 '13 at 17:28
  • actually i don't want to convert to windows-1255... im just tring to find a way to make it works and looks in hebrew – user2730162 Aug 29 '13 at 17:28
  • Looks like mb_convert_encoding is treating your Windows-1255 input as ISO-8859-1 or Windows-1252. Does the function at http://stackoverflow.com/questions/15593394/encoding-issues-windows-1255-to-utf-8 work for you? – PleaseStand Aug 29 '13 at 17:42
  • still not working. to clarify the situation: after using mb_convert_encoding($data[5],"utf-8"), i get string that contains gibbrish as above... is there anyway to treat that gibbrish string and make it utf8? – user2730162 Aug 29 '13 at 17:56
  • What does `echo win1255ToUtf8($data[5]);` give you? (The code for win1255ToUtf8 is on the page I linked to.) – PleaseStand Aug 29 '13 at 18:35
  • it changed the gibberish (éåâá ) to another unknown type to chars: ֳ°ֳ¥ֳ¹ֳ – user2730162 Aug 29 '13 at 18:55

0 Answers0