Avoid some charset lookups

Background info at e.g. http://bugs.mysql.com/bug.php?id=61105
Merge pull request #1535 from scop/charset-lookup

Avoid some charset lookups