How to handle international character in PHP / MySQL / Apache

I need to create a PHP application that can handle all Unicode characters in all places - edit fields, static HTML, database. Can someone tell me a complete list of all the parameters / functions that need to be installed / used to achieve this?

+2
source share
5 answers

Apache

Server-side encoding must either not be installed or installed in UTF-8. This is done using the apache AddDefaultCharset directive. This can go to a virtual host or shared file (see the documentation).

AddDefaultCharset utf-8

Mysql

  • Set to sort the UTF-8 database
  • . , - mysqli_set_charset, :
    SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'

PHP

1- HTML- UTF-8, PHP:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-or-
    header('Content-type: text/html; charset=utf-8');

2- , mb *, , mbstrlen strlen, .

UTF-8 , . , : firefox " ". .

+7

: , UTF-8 Mysql PHP!

mysqli

mysqli_set_charset($dblink, 'utf-8')

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

+1

, : -

PHP

, utf-8:

default_charset = "utf-8"

mbstring.

, utf-8 PHP MySQL.
mysql_set_charset("utf8"); ( SQL- SET NAMES utf8)

Apache

Content-Type:

AddDefaultCharset utf-8

MySQL

, utf8 Collation utf8_general_ci; ,

ALTER DATABASE mydb CHARACTER SET utf8;

, ,

9 (อก เน ฬฏอก เน) 6

...

+1

HTTP-, -, utf-8. W3C . - . ( - ASCII, . , , .)

, , , accept-charset="utf-8". , POST, , .

+1

I used the methods mentioned and they worked perfectly. Until recently, when my provider upgraded PHP to 5.2.11 and MySQL to the 5.0.81 community. After this change, Unicode characters were correctly extracted from the database, but all updates were corrupted, and Unicode characters were replaced with "?".

The solution was to use:

mysql_set_charset('utf8',$conn);

This was required, although we used:

SET NAMES utf8
SET CHARACTER SET utf8

Also, since we used ADOdb, we needed to find a PHP connection handle. We used the following statement:

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

All Articles