Skip to main content

Displaying TIS620 mysql on UTF8 page

Submitted by admin on

The ghost from the past is my MySQL database encoded in tis620. Worse, the table and the column itself is labelled as iso-8859-1. Of course, if the web page is to be "viewed" as tis620, all I must to is to simply use

SET NAMES tis620; SET CHARACTER SET tis620;

In my php code. However, this is not the case because the page itself is utf8.

What comes to help me is iconv. In short, this is what I did.

db_query(\"SET CHARACTER SET latin1\"); $query = \"SELECT * FROM table1 $result = db_query($query); $number_of_rows = $result->rowCount(); foreach ($result as $record) { printf iconv(\"ISO-8859-11\", \"UTF-8\", $record->comment) echo '</tr>'.\"\\n\"; } db_query(\"SET CHARACTER SET utf8\");