问题描述
我有一个Webapp,它在MySQL数据库中存储法语文本(可能包含重音字符).通过PHP直接检索数据时,带重音的字符变得乱码.例如:qui r�fl�te la liste.
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 characters become gibbirish. For instance: qui r�fl�te la liste.
因此,我使用htmlentities()
(或htmlspecialchars()
)将字符串转换为html实体,一切都很好.但是,当我输出包含重音字符和HTML元素的数据时,事情变得更加复杂.例如,<strong>
被转换为<strong>
,因此浏览器无法理解.
Hence, I use htmlentities()
(or htmlspecialchars()
) to convert the string to html entities, and all is fine. However, when I come to output data that contains both accented characters and HTML elements, things get more complicated. For instance, <strong>
is converted to <strong>
and therefore not understood by the browser.
如何同时正确显示带重音符号的字符和正确解析我的HTML?
How can I simultaneously get accented characters displayed correctly and my HTML parsed correctly?
谢谢!
推荐答案
也许您可以看看utf8_encode()
和utf8_decode()
这篇关于存储在MySQL数据库中的重音字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!