Reputation: 1957
I have a PHP/MySQL application, where it needs to work with UTF-8 characters behind-the-scenes (the UTF-8 characters won't be shown on-screen). The UTF-8 characters are from a PHP cURL request.
What do I need to do to make PHP and MySQL properly function with UTF-8 characters?
Do I need to set default_charset = utf-8
in php.ini? Or is this
only used when data is displayed on-screen?
Do I need to set the character set/collation to utf8/utf8_general_ci for my databases, tables, and columns?
I read that there's also a such thing as connection character sets for MySQL. Does this really matter?
Thanks for the help.
Upvotes: 0
Views: 443
Reputation: 24151
Consider to use UTF-8 for everything, the php files, the HTML encoding and the database, it will save you a lot of troubles. You won't need to convert between encodings, you can use all possible characters of all encodings, and you can do without HTML entities.
I collected some tips of how to make your site UTF-8 only. Should you already have a database in a different encoding, that's no problem, just tell the connection object to deliver UTF-8.
$db = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);
$db->set_charset('utf8');
Upvotes: 1
Reputation: 154
You can use following php in-built functions to iso characters to utf8 charset
utf8_encode(CHARACTERS);
Upvotes: 0