Akram
Akram

Reputation: 423

cannot display chinese characters in php

Hi guys I have an issue to display chinese character in simple php file, I cannot figure out how to get it solved

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
 <?php
 define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
 ?>
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
    </head>
    <body>

电视机/電視機
    </body>
</html>

I am think this can be the issue of apache or php.ini configuration. Any idea how to solve this issue?

Upvotes: 1

Views: 10449

Answers (4)

drexsien
drexsien

Reputation: 952

sorry did not get the question, but for thos who are getting the data from db try adding

mysql_query("SET NAMES 'utf8'"); in your db connection

Upvotes: 0

Zheng Kai
Zheng Kai

Reputation: 3635

Use <meta charset="utf-8"> before <title>

Some old style browers checks http header first, so you may set

<?php
header("Content-Type: text/html; charset=utf-8");

or change your web server config file

Example in Nginx:

add this lines after server {

charset utf-8;
charset_types
    text/css
    application/javascript
    application/x-javascript
    text/xml
    text/plain;

Example in Apache:

AddDefaultCharset Off

or

AddDefaultCharset utf-8

Upvotes: 3

arma
arma

Reputation: 4124

As you are using html5 you can use

<meta charset="utf-8">

and it will your fix issue.

If you are not using html5 then changing value to content will fix it

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

Upvotes: 2

cgajardo
cgajardo

Reputation: 364

Try using this:

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

You write value instead of content

Cheers!

Upvotes: 2

Related Questions