我在查看使用CodeIgniter从mysql数据库中恢复的Tamil内容时遇到问题。但相同的代码在核心PHP中工作。我已在下面附上我的代码。如果有任何变化,请检查我的代码并给出答案。
这是我的观看代码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<table class="table table-striped table-bordered table-hover dataTables-example" >
<thead>
<tr>
<th>Title</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
foreach ($per_results as $result)
{
?>
<tr class="">
<td><?php echo $result->title;?></td>
<td><?php echo $result->description;?></td>
</tr>
<?php
}
?>
</tbody>
</table>
这是我的Controller COde:
public function view_mainhome()
{
$data['per_results'] = $this->Login_model->getview_permission();
$this->load->view('forest_add/view_mainhome',$data);
}
这是我的标准代码:
function getview_permission() //Stock
{
$this->db->select('*');
$this->db->from('forest_permission');
$this->db->order_by("per_id", "asc");
$query = $this->db->get();
return $query->result();
}
谢谢@
答案 0 :(得分:1)
根据我的评论,
将SQL列的数据类型更改为 utf8_general_ci
答案 1 :(得分:0)
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
请在文档标题中尝试此代码。我希望这对泰米尔语有用。
答案 2 :(得分:0)
@ user3839366 utf8_general_ci
是排序规则,请确保您对加入并比较的其他表字段具有相同的排序规则。
我要把这个留给其他有utf8问题的人。如果您有unicode字符,则可以在创建表时执行此操作,
CREATE TABLE `your_table_name` (
....
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
或更晚
ALTER TABLE `your_table_name` CONVERT TO CHARACTER SET utf8;
具体的整理
CREATE TABLE `your_table_name` (
....
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
或以后
ALTER TABLE `your_table_name` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
注意: - 如果你想要完全支持unicode(例如,在数据库中存储表情符号),你可以使用utf8mb4
此外,如果您想在控制台中查看结果,请运行set names utf8;
(也适用于没有开箱即用unicode支持的程序或脚本)
答案 3 :(得分:0)
使用以下mysqli函数,我们可以实现100%工作
config['set_charset']=array( $db, 'utf8');
替换$ db代替您的db连接变量。