Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Hebrew XML

Hello I'm having problems parsing hebrew xml file. I use file_get_contents to read the file, and when I display it I get weird charaters. I searched all over the internet and found many functions and none works.

Input:

<ROW>
  <C0>1</C0>
  <טבלה>טבלת ישובים</טבלה>
  <סמל_ישוב>967</סמל_ישוב>
  <שם_ישוב>אבו ג'ווייעד )שבט(</שם_ישוב>
  <סמל_נפה>62</סמל_נפה>
  <שם_נפה>באר שבע</שם_נפה>
  <סמל_לשכה_מנא>62</סמל_לשכה_מנא>
  <לשכה>באר שבע</לשכה>
  <סמל_מועצה_איזורית>0</סמל_מועצה_איזורית>
  <שם_מועצה> </שם_מועצה>
</ROW>

Output:

> ROWDATA>

> ROW>
> C0>1
<äìáè\>íéáåùé úìáè<äìáè>
<áåùé_ìîñ967
<áåùé_íù\>)èáù( ãòééåå'â åáà<áåùé_íù>
<äôð_ìîñ62
<äôð_íù\>òáù øàá<äôð_íù>
<àðî_äëùì_ìîñ62
<äëùì\>òáù øàá<äëùì>
<úéøåæéà_äöòåî_ìîñ0
<äöòåî_íù\> <äöòåî_íù>
\> ROW>

The code I'm using is:

$xml = file_get_contents('hebrew.xml');
echo hebrevc($xml);

I tried with outputing header before:

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

I also tried with utf8_encode and I get all the the time wrong charachers. Please help me out :/

like image 765
Aleksandar Vasić Avatar asked Feb 22 '26 07:02

Aleksandar Vasić


1 Answers

Try this:

 $xml = file_get_contents('hebrew.xml');
 mb_convert_encoding($xml, 'UTF-16LE', 'UTF-8');
 echo $xml;
like image 138
Yair.R Avatar answered Feb 24 '26 21:02

Yair.R