mysql读取数据后编码有问题,求高手

WBOY
Release: 2016-06-23 14:11:45
Original
839 people have browsed it

smarty 编码 数据库 MySQL


这是我注册的一个smarty函数
function charsetUTF8($params) {								extract($params);										$str=iconv("gb2312","UTF-8",$text);	return $str;										}$smarty->register_function("Util", "charsetUTF8");	   				
Copy after login





{section name=gro_id loop=$gro}				 						         <option value="{$gro[gro_id].id}">{Util text=$gro[gro_id].u_group}</option>									{/section}
Copy after login



可读出来的是乱码



现在数据库的字段编码是gb2312,文件开头也有规定编码,为什么出问题啊
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Copy after login


我试过将数据库的编码改为utf-8,不使用我注册的那个smarty函数,还是有问题,求助各位大神。。。

回复讨论(解决方案)

echo  charsetUTF8($params);  这里乱码吗

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template