try {
$driverOptions = [
- \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
+ \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'"
];
if (!$this->failsafeTest) {
$driverOptions = [
- \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
+ \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
];
}
".$columnDefinition."
".(!empty($indexDefinition) ? ',' : '')."
".$indexDefinition."
- ) ENGINE=".($hasFulltextIndex ? 'MyISAM' : 'InnoDB')." DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+ ) ENGINE=".($hasFulltextIndex ? 'MyISAM' : 'InnoDB')." DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
}
public function readUserInput(array &$source) {
parent::readUserInput($source);
- // remove 4 byte utf-8 characters (e.g. emoji)
foreach ($this->rawValues as &$value) {
if (is_string($value)) $value = MessageUtil::stripCrap($value);
}
// unify new lines
$text = StringUtil::unifyNewlines($text);
- // remove 4 byte utf-8 characters as MySQL < 5.5 does not support them
- // see http://stackoverflow.com/a/16902461/782822
- $text = preg_replace('/[\xF0-\xF7].../s', '', $text);
-
// remove control characters
$text = preg_replace('~[\x00-\x08\x0B-\x1F\x7F]~', '', $text);