Quantcast
Channel: Eureka! » PHP
Viewing all articles
Browse latest Browse all 16

PHP – Write file in specific charset/encoding

$
0
0

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.

$big5_str = iconv('UTF-8', 'Big5', $utf8_str);

 

Done =)

Reference: StackOverflow – PHP – UTF-8 to Chinese ANSI (GB2312?) – Export CSV file


Filed under: PHP Tagged: Big5, PHP, UTF-8

Viewing all articles
Browse latest Browse all 16

Trending Articles