本文介绍了使用mysql_set_charset('utf8')函数后用UTF-8替换字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将所有mysql表转换为utf-8_unicode并使用mysql_set_charset('utf8');函数开始.

I converted all mysql tables to utf-8_unicode and started using mysql_set_charset('utf8'); function.

但是此后,,、Ö等某些字符开始看起来像Ö,Åž

But after this, some characters like Ş, Ö started looking like Ö , Åž

如何用UTF-8格式替换mysql中的这种字母?

How can i replace this kinda letters in mysql with UTF-8 format ?

很快,我可以找到所有这些要替换的字符的列表吗?

shortly, can i find a list of all these kinda characters to replace ?

他实际上是在这篇文章中解释了这个问题,但我无法完全正确地理解它,大声笑

He is explaining about this issue in this article actually but i cannot understand it properly acutally lol

http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html

推荐答案

您不需要这样做.只需在数据库连接后使用此代码即可.

you dont need to do that. just use this code after database connect.

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");

并在所有页面中使用utf-8字符集.

and use utf-8 charset in all of your pages.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

这篇关于使用mysql_set_charset('utf8')函数后用UTF-8替换字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 23:36