简体   繁体   中英

how to display this chinese character?

I already set mySQL Collation as utf8_unicode_ci, if I manual insert chinese character in my database, it's successful work to displaying chinese character, but once i use my code, it was display this

ã€å¼µç'žæŒ¯ã€æ±Ÿç¥¥ç¶ ..

I had add this <meta http-equiv="Content-Type" content="text/html;charset=utf-8" ></meta> in my header, I had try utf8_encode ,but still the same problem happen.

thank you and hope you guy reply me soonest

Have you set the connection character set / collation? Execute this query immediately after creating a connection

SET NAMES 'utf8'

You have probably forgot to execute this query after connecting

SET NAMES utf8 

Try it and you'll see

there 2 steps you should do

  1. add a query with UTF8

    $query = "SET NAMES 'utf8'";

    mysql_query($query);

  2. make sure your file is encoded as UTF8, open your script with your favourite editor and save as UTF8

To ensure MySQL expects UTF-8 encoding by default from client connections, use the following query:

SET NAMES 'utf8'

In addition, make sure PHP interprets the string as UTF-8 string. Since PHP does not support multibyte characters, you must use a function to allow PHP to work with UTF-8 strings:

utf8_decode()

or something.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM