请教UTF8和GBK编码问题

WBOY
Release: 2016-06-23 13:33:28
Original
1353 people have browsed it

用zendstudio 10写了个项目,是用UTF8编码的,但是数据库是GBK的,就导致了乱码问题。现想把整个项目文件都改成GBK编码,请问最快的方法是?


回复讨论(解决方案)

无论是程序还是数据库都不要修改字符集
你只需在连接数据库后通知 mysql 使用什么字符集
对于你现在的情况就是
mysql_query("set names utf8");

无论是程序还是数据库都不要修改字符集
你只需在连接数据库后通知 mysql 使用什么字符集
对于你现在的情况就是
mysql_query("set names utf8");


斑竹 我用的是pdo和oracle数据库,怎么搞呢?
我恍惚想起了这么一句:
$db = "oci:dbname=//localhost:1521/orcl;charset=zhs16gbk";
$conn = new PDO($db,$dbuser,$dbpassword);
是这样吗?

这样好像写入oracle没问题了 可是中文读不出来 只能用iconv了吗?

charset=zhs16gbk 是使用 gbk 字符集
charset=utf-8 才对吧?

时间长了都忘了

charset=zhs16gbk 是使用 gbk 字符集
charset=utf-8 才对吧?

时间长了都忘了


嗯。。好像都可以 只是无论怎样 在读或写的时候还是要转一下 好麻烦。。
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!