使用php从MySql数据库检索印度语数据显示不寻常的字符集

时间:2017-07-04 06:24:53

标签: php android mysql utf-8

我正在用印度语检索数据而且我得到的输出是????????????????????????????????

注意: - 我在我的php脚本中使用了这两行

header('Content-type: text/plain; charset=utf-8');
mysqli_set_charset($conn,'utf-8');

我也在数据库和表中使用了utf8_general_ci编码。

我的php脚本是

<?php

require 'init.php';

header('Content-type: text/plain; charset=utf-8');
mysqli_set_charset($conn,'utf-8');

$table = $_GET['table_name'];

$sql = "SELECT * FROM ".$table;

$response = array();

$result = mysqli_query($conn,$sql);

if(mysqli_num_rows($result)>0) {
        while($row = mysqli_fetch_array($result)) {
        array_push($response, array('id'=>$row['id'],'text'=>$row['text']));
    }
    echo json_encode($response);
} else {
    echo "error";
}

mysqli_close($conn);

?>

您可以查看链接http://www.sharefb.com/statusApp/readStatus.php?table_name=gujrati_attitude

3 个答案:

答案 0 :(得分:0)

使用mysqli_set_charset($ db,'utf8');

答案 1 :(得分:0)

在标题中添加此元标记并尝试

<META HTTP-EQUIV="Content-Type" CONTENT="text/html"; charset="utf-8" />

注意:如果结果显示为????那么你可能需要通过启用以下选项来安装外部语言支持工具,

控制面板 - &gt;区域和语言选项 - &gt;语言 - &gt;安装复杂脚本和从右到左语言(包括泰语)的文件。

答案 2 :(得分:0)

参见&#34;问号&#34;在Trouble with utf8 characters; what I see is not what I stored

如果仍有问题,请提供

显示创建表
正在插入的文本示例
选择坏数据样本的HEX(...)(? = 3F