Sometimes we need to specify the file charset before writing the data to a file. The data strings which we get from the database are in UTF-8 so we have to convert them in proper charset. This could be done be iconv().
For example, i want to write the Traditional Chinese in Big5. The conversion could be done by.
Continue reading PHP – Write file in specific charset/encoding
Quite often i will use Microsoft Excel to edit CSV file. But sometimes you may find garbled characters in the opened file and it is caused by the file encoding.
For example, Excel could not view UTF-8 file. So if you got a CSV encoded in UTF-8, you need to convert it to ANSI encoded. This could be done by opening the CSV file in Notepad and then save it as new file in ANSI encoding. Continue reading Garbled characters when opening CSV in Microsoft Excel
The dompdf is a PHP library which help you to convert HTML into a PDF file. Actually i haven’t tried to implement it by myself but recently, i followed an project which used the dompdf and there is a UTF-8 decoding issue for special character like an Apostrophe. Continue reading PHP – dompdf UTF-8 decode problem
I am not familiar with the character encoding. I have a ISO-8859-1 string(Big5). After i convert it to UTF-8 by the utf8_encode() function, garbage characters are shown in the HTML. Finally, i found another way to convert Big5 to UTF-8.
The following function will break down a Big5 string into characters and convert them into UTF-8 one by one. Continue reading PHP – Convert Big5 to UTF-8