CHARSET, qu'est-ce que l'encodage et comment configurer son serveur?
MySQL
SHOW SESSION VARIABLES like "char%"; SHOW GLOBAL VARIABLES like "char%";
// SESSION character_set_client => utf8 character_set_connection => utf8 character_set_database => latin1 character_set_results => utf8 character_set_server => latin1 character_set_system => utf8 character_sets_dir => /usr/share/mysql/charsets/
// GLOBAL character_set_client => latin1 character_set_connection => latin1 character_set_database => latin1 character_set_results => latin1 character_set_server => latin1 character_set_system => utf8 character_sets_dir => /usr/share/mysql/charsets/
PHP
define('CHARSET' , 'utf-8'); // utf-8, iso-8859-15, cp1252... define('LOCALE' , 'fr_FR'); // Attention aux diff. systemes (windows / linux) define('MYSQL_CHARSET' , 'UTF8'); // UTF8, latin1... @ini_set('default_charset', CHARSET); setlocale(LC_ALL, LOCALE, 'fr_FR.'.CHARSET, 'fr_FR', 'fra'); header('Content-Type: text/html; charset=' . CHARSET); $sql = "SET NAMES " . MYSQL_CHARSET; mysql_query($sql);
HTML
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Questions liées à cette page