UTF-8 Everywhere

Submitted by michael on Mon, 10/17/2016 - 12:26
Apache, PHP, and web browsers default to ISO-Latin-1 (aka latin1). MySQL defaults to latin1, with the latin1_swedish_ci collation. None of that is any good. Apache Configuration: AddDefaultCharset utf-8 php.ini: default_charset = "utf-8" mbstring.internal_encoding=utf-8 mbstring.http_output=UTF-8 mbstring.encoding_translation=On HTML: MySQL: SET NAMES utf8mb4; CREATE DATABASE CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; Symfony's config.yml: doctrine: dbal: ... charset: utf8mb4 default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci Overriding functions is a dangerous area, so always use the /u regex modifier, and consider calling mb_regex_encoding('UTF-8') before regexes.