Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thai, Vietnamese language not supported in Excel

I have created an excel in which it has Thai and Vietnamese language. My problem is that it is showing these characters as question marks.

My code is below

$worksheet->write($i, 5, iconv("UTF-8", "ISO-8859-1//TRANSLIT", html_entity_decode($text)), $mainquest);

I have also tried all the other ISO standards. I put ISO-8859-1 for french language support. I also tried the mb_convert_encoding but no progress.

Is there any solutions for this?

like image 684
Preethy Avatar asked Jun 28 '16 08:06

Preethy


2 Answers

The encoding charset is not the same as French for Vietnamese and Thai

For Vietnamese (Windows) - charset=windows-1258

For Thai (Windows) -charset=windows-874

so for Thai:

$worksheet->write($i, 5, iconv("UTF-8", "windows-874",html_entity_decode($text)), $mainquest);

and for Vietnamese:

$worksheet->write($i, 5, iconv("UTF-8", "windows-1258",html_entity_decode($text)), $mainquest);
like image 75
coolstoner Avatar answered Oct 02 '22 16:10

coolstoner


If switching the library is an option I'd suggest to use phpexcel. It is UTF8-based, which means you shouldn't get into trouble with character encoding at all (if everything else is neatly set to utf-8 in your workflow – db,files, webserver). Never had any problems with this library so far, while having generated spread sheets with all kind of special characters.

like image 35
Hafenkranich Avatar answered Oct 02 '22 14:10

Hafenkranich