donglianglu8136 2013-09-28 20:03
浏览 61
已采纳

Charset错误,php smarty mysql

I've recently come across a weird problem about the meta charset.

If I don't set any charset in my header, all accent like é,è,à.. are show correctly (even var from php) except for text comming from my database are replace by a little question marks in a lozenge.

If I set one of those(I tried both of them) charset in my header

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

Text from my database is okay, but all the rest show the little question marks instead of the accent.

My database character set is UTF-8 unicode, and Collation is UTF_8 general_ci.

Note that I'm using smarty, but I did'nt change the charset in config cause his default is UTF-8.

  • 写回答

1条回答 默认 最新

  • douejuan9162 2013-09-30 21:42
    关注

    Okay I found a solution, I'm using an ORM, and i only add the charset=utf8 in the setConnection method like this

    $config->set_connections(array(
        'development' => 'mysql://user:pass@localhost/mydb;charset=utf8')
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?