I have to create a credit card applicatoin in Php that may handle all unicode figures in most places - edit fields, static html, database. Can somebody let me know the entire listing of all parameters / functions that should be set / used to do this goal?

Apache

The server encoding should be either not set, or set to UTF-8. This is accomplished through the apache AddDefaultCharset directive. This can turn to the virtualhost or even the general file (see documentation).

AddDefaultCharset utf-8

MySql

  • Set the collation from the database to become UTF-8
  • Set the bond encoding. It is possible as someone stated with mysqli_set_charset, or by delivering this soon after hooking up:

    SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'

PHP

1- You need to set the HTML charset from the page to become UTF-8, using a meta tag around the page, or using a PHP header:


    <meta http-equiv="Content-Type" content="text/html charset=utf-8" />

-or-

    header('Content-type: text/html charset=utf-8')

2- It is best to make use of the megabytes* version of string-related functions, for instance, mbstrlen rather than strlen to obtain the string period of a string.

This will give you UTF-8 everywhere, in the pages towards the data. An evaluation that you can do: right-click anywhere around the page using opera, and choose Show page information. The effective encoding shows up for the reason that page.

Important: It's also wise to make sure that you use UTF-8 as connection charset when hooking up to Mysql from PHP!

For mysqli this is accomplished by

mysqli_set_charset($dblink, 'utf-8')

http://de3.php.net/manual/en/mysqli.set-charset.php

Several things you will have to consider:-

PHP

Make certain your articles is marked as utf-8 :

default_charset = "utf-8"

Install mbstring. You'll find it here

Make sure that you are speaking utf-8 between PHP and MySQL.
Call mysql_set_charset("utf8"); (or make use of the SQL query SET NAMES utf8)

Apache

Additionally you set the Content-Type: of the pages in here with something similar to this

AddDefaultCharset utf-8

MySQL

Make certain all of your tables use utf8 Collation utf8_general_ci eg

ALTER DATABASE mydb CHARACTER SET utf8;

Finally

Finally, test stuff with fun unicode samples, like these ones

٩(͡๏̯͡๏)۶

More useful information from when I tried this...

You had been suggested to make use of whether HTTP header or perhaps a meta element to create the charset in your pages to utf-8. The W3C suggests that you simply do both. And also the meta element should appear as soon as possible around the page. (All figures prior to the meta element ought to be ASCII, that is essentially identical in just about all character encodings. Some browsers will restart page rendering once they encounter the meta tag, that is one other good reason to be early.)

Also, on all forms accepting user input put an accept-charset="utf-8" attribute. Generally browsers posting Publish data will default towards the encoding from the page, but it is no harm to be certain.

I made use of the pointed out techniques plus they labored fine. Until lately, when my provider has up-to-date PHP to five.2.11 and MySQL to five..81-community. Following this alter the unicode figures were correctly retrieved in the database, but all updates were corrupted and unicode figures had been changed by '?'.

The answer ended up being to use:

mysql_set_charset('utf8',$conn);

It had been needed despite the fact that we used:

SET NAMES utf8
SET CHARACTER SET utf8

Also - since we've used ADOdb only then do we needed to obtain the PHP connection handle. We used the next statement:

mysql_set_charset('utf8',$adoConn->_connectionID);