我有一个数据库,在那个词中是utf-8编码的

我正在通过下面的代码读取数据库
<?php
header("Content-Type: text/html;charset=UTF-8");
include("./config.php");
$sql=mysql_query("SET NAMES 'utf8'");
$sql=mysql_query("SELECT * FROM `Albanian` WHERE (`COL 2`='".$_GET['q']."')");
$rowCount = mysql_num_rows($sql);
if($rowCount > 0)
{
while($row = mysql_fetch_array($sql))
{
echo utf8_encode($row['COL 3']);
}
}else
{
echo "No Word Found";
}
?>但是,如果我使用单词"a“进行搜索,输出结果如下所示
+

与UTF-8不同的是,有人能帮我解决这个问题吗?
发布于 2013-11-26 13:37:54
您的数据已经是utf-8格式,不需要调用utf8_encode
发布于 2013-11-26 13:34:47
<meta http-equiv = "Content-Type" content = "application/xhtml+xml; charset=utf-8"/>
<?php
include("./config.php");
$sql=mysql_query("SET NAMES 'utf8'");
$sql=mysql_query("SELECT * FROM `Albanian` WHERE (`COL 2`='".$_GET['q']."')");
$rowCount = mysql_num_rows($sql);
if($rowCount > 0)
{
while($row = mysql_fetch_array($sql))
{
echo $row['COL 3'];
}
}
else
{
echo "No Word Found";
}
?>发布于 2013-11-26 13:35:52
浏览器很挑剔。尝试使用适当的HTML5文档输出。请参阅来自http://www.w3schools.com/html/html5_intro.asp的“最小HTML5文档”
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
Content of the document......
</body>
</html>另外,我不记得我是从哪里得到这个的,但是我为我做的每个php项目都使用了一个.htaccess文件,并且如果我有控制的话,我总是坚持对每个项目使用UTF-8。
# MAKE SURE WE GET ERROR REPORTING
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
# USE UTF-8
php_value mbstring.language neutral
php_value mbstring.internal_encoding utf-8
php_value mbstring.encoding_translation on
php_value mbstring.http_input auto
php_value mbstring.http_output utf-8
php_value mbstring.detect_order auto
php_value mbstring.substitute_character none
php_value default_charset utf-8https://stackoverflow.com/questions/20209054
复制相似问题