setting utf8 with mysql through php

后端 未结 2 880
忘了有多久
忘了有多久 2020-12-21 23:12

I have the following very simple code, which retrieves utf8 formatetd data, such as containing umlauts from a mysql database, which may or may not be set as utf8. If I use e

相关标签:
2条回答
  • 2020-12-21 23:35

    Perhaps the error lies in the charset you're serving the page with. If you're getting UTF-8 content out of the database and serving it with the default HTML charset of Windows-1252 then it's going to look garbled. Make sure you have the equivalent of this:

    header( 'Content-Type: text/html; charset=utf-8' );
    

    in your PHP code.

    0 讨论(0)
  • 2020-12-21 23:45
    1. Make sure your data is already UTF-8 encoded in your database
    2. configure database to deliver UTF-8 (eg. SET NAMES 'utf8')
    3. use the right encoding on your website (nod to stak)

    If you still have problems, please provide more data, especially what is expected and what finally delivered

    0 讨论(0)
提交回复
热议问题