存储在MySQL数据库中的重音字符 [英] Accented characters stored in MySQL database

查看:90
本文介绍了存储在MySQL数据库中的重音字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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>被转换为&lt;strong&gt;,因此浏览器无法理解.

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 &lt;strong&gt; 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数据库中的重音字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆