Foreign characters appearing in the browser when db and browser encodings differ

phpMyAdmin seems to have a fondness for the swedish character encoding, so all databases created have that encoding. This, and moving content via differing means ofter results in spurious foreign characters appearing in the browser from content renders from the db.

The answer is simple - ensure when the connection is first made to the database run the SQL statement:


This forces the connection to be utf-8, which should also be set in the browser by the meta content attribute.


Tags: mysql, web