Accented characters stored in MySQL database

后端 未结 3 1943
逝去的感伤
逝去的感伤 2020-12-07 04:12

I have a webapp that stores French text -- which potentially includes accented characters -- in a MySQL database. When data is retrieved directly through PHP, accented chara

相关标签:
3条回答
  • 2020-12-07 04:46

    You should use UTF-8 encoding for storing the data in the database - then everything should work as expected and no htmlentities() will be required.

    Make sure all aspect are utf-8 - the database, the tables encoding and collation, and the connection, both on the client and server side. Things might work even if not everything is utf-8, but might fail horribly when you will do backup & restore - that is why I recommend utf-8 across the board.

    0 讨论(0)
  • 2020-12-07 04:49

    Maybe you could take a look to utf8_encode() and utf8_decode()

    0 讨论(0)
  • 2020-12-07 04:51

    You could set the Collation of the database fields containing the accented character to utf8_general_ci to support them.

    Eventually you can set the collation of the database as well, so all fields are set by default.

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