【问题标题】:Utf8 - How to clean these strings?Utf8 - 如何清理这些字符串?
【发布时间】:2011-07-28 10:04:27
【问题描述】:

我用

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

带有“utf8_general_ci”的Mysql数据库

但我得到了这些字符串

  • 马鞍俱乐部 3ã�​â&de​g;
  • Speciale Aldo Moro02/04/�

如何清理所有这些字符串?

【问题讨论】:

  • 它在数据库中的样子? (例如来自 phpMyAdmin)? “Saddle Club 3ã�â&de​g;”在数据库中代表什么?
  • 你从哪里得到这些字符串?这需要更多信息。
  • “我得到这些字符串”在哪里,如何?

标签: php utf-8 character-encoding non-ascii-characters


【解决方案1】:

你需要设置你的mysql数据库连接的编码。

$this->mysqli->query('SET NAMES utf8'); //on your mysqli instance
or
mysql_query('SET NAMES utf8'); // simple mysql query

不知道您使用什么类型的连接,但这可能会有所帮助..

【讨论】:

    【解决方案2】:

    您的查询是否使用任何 utf-8 设置?

    喜欢:

    mysql_query("SET CHARACTER SET utf8", $this->connection);
    mysql_query("SET NAMES utf8", $this->connection);
    $result = mysql_query($sql, $this->connection);
    

    【讨论】:

      猜你喜欢
      • 2015-08-18
      • 2022-10-12
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      • 2013-04-14
      • 2020-03-03
      • 1970-01-01
      相关资源
      最近更新 更多