Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php to rtf, é becomes é

Using this rtf class, I see my special characters getting converted, like é becomes \'C3\'A9 (that part is probably not the problem)

Once I get it in rtf using php header, the resulting character (é) is seen as é.

header("Content-type: application/rtf; charset=utf-8");
header("Content-Disposition: attachment; filename=$file_rtf");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); 

Strange! My file is saved in utf-8, for information.

I had a similar problem while getting excel, but that is solved using

$text = mb_convert_encoding($text,'utf-16','utf-8');

This is not working for rtf. Thanks for any help.

PS. My file is saved with utf-8 encoding thro' DW, and my mysql default charset is also utf-8. I don't have a problem when I display a character directly from the database, but this problem is seen only when I type a special character directly into the page before to use the header.

Cheers.

like image 819
Jeremy Roy Avatar asked Dec 03 '22 08:12

Jeremy Roy


1 Answers

Well, finally I solved it using:

mb_convert_encoding($text,'ISO-8859-15','utf-8');
like image 81
Jeremy Roy Avatar answered Dec 26 '22 16:12

Jeremy Roy