Skip to content

Instantly share code, notes, and snippets.

@meglio
Last active August 29, 2015 14:16
Show Gist options
  • Save meglio/23c03436410ea0840ce2 to your computer and use it in GitHub Desktop.
Save meglio/23c03436410ea0840ce2 to your computer and use it in GitHub Desktop.
<?php
$s = 'Iñtërnâtiônàlizætiøn-р X';
$pdo = new PDO('mysql:host=localhost;dbname=fa', '...', '...', [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET CHARACTER SET utf8',
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
$res = $pdo->query('SELECT label FROM connectors WHERE id = 18', PDO::FETCH_COLUMN, 0);
$sDB = $res->fetchColumn();
echo "s : ".mb_detect_encoding($s)."\n";
echo "sDB: ".mb_detect_encoding($sDB)."\n";
@meglio
Copy link
Author

meglio commented Mar 5, 2015

Output:

s : UTF-8
sDB: UTF-8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment