Colorfulstan
10/9/2015 - 4:51 PM

From http://kkovacs.eu/how-not-to-mess-up-encodings How to ensure utf-8 encoded database / html / php

From http://kkovacs.eu/how-not-to-mess-up-encodings

How to ensure utf-8 encoded database / html / php

CREATE TABLE `table` (
  `ID` bigint(20) unsigned NOT NULL auto_increment,
  `TEXT` longtext NOT NULL,
  PRIMARY KEY  (`ID`),
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
//Next, set the HTTP connection to use UTF-8. This means addig this code early on (your head.inc or //similar):

header('Content-Type: text/html; charset=utf-8');
//From your PHP code, set your MySQL connection up to use UTF-8 all the time (if not configured so by //default, but usually it is not). This means the following SQL right after connecting to the DB:

set character_set_results=utf8, character_set_client=utf8, character_set_connection=utf8;
<!-- and, for safety and consistency, also adding this to your html-head output: -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />