0

I have a html file that want pars tags(Title,A,Name,...) and save them to a excel file . html tags is persian and when save them into excel file not save corectly. html file:

<html dir="rtl"><head><meta http-equiv="Content-Language" content="fa">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>ÈÇäß ÕæÊ.ÂãæÒÔ.ÇÏÈíÇÊ.ÚæÇãá Ýí ÇáäÍæ.ÇÓÊÇÏ ãÏÑÓ ÇÝÛÇäí.ÌáÓå 1</title>
<meta name="generator" M.H.SAFARZADE TEHRANI   E_BANK_JAME_EMAMALI>

for example i want save title but not save corectly . title tag trust value is :

تدريس استاد مدرس افغاني

but save : ÈÇäß ÕæÊ.ÂãæÒÔ.ÇÏÈíÇÊ.ÚæÇãá Ýí ÇáäÍæ.ÇÓÊÇÏ ãÏÑÓ ÇÝÛÇäí.ÌáÓå 1

in php file i do this :

mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
ob_start('mb_output_handler');

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

and :

$str = mb_convert_encoding($title, "UTF-8");

i can't find answer for my question in web.

please help me ...

thank you

4
  • possible duplicate of php header excel and utf-8 Commented Jun 5, 2014 at 7:21
  • can this help you? stackoverflow.com/questions/6175053/… Commented Jun 5, 2014 at 7:24
  • 1) The encoding of the original appears to be Windows-1256 (according to the meta tag); you will have to do an explicit conversion from Windows-1256 to UTF-8 at some point. 2) How exactly are you passing the data to Excel? If you're producing an actual .xls(x) file with libraries which support just that, it should work. If you're just dumping CSV data, Excel notoriously sucks at importing CSV data correctly (or other plaintext formats for that matter). So in that case, confirm whether it looks okay using a good text editor first, instead of Excel. Commented Jun 5, 2014 at 7:24
  • 1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.