Is there a way of retrieving the current character set with PDO? I used to have a little test with Mysqli to check if the forced character set was set by retrieving it like
If you want the actual charset (not collation) you can do this:
$charset = $pdo->query("SELECT CHARSET('')")->fetchColumn(); if($charset === 'utf8mb4') { $charset = 'utf8'; }
I put the utf8mb4 check in there because it's not compatible with PHP's mb_ functions.
utf8mb4
mb_