在 PHP 中显示从 MYSQL 提取的数据的重音符号
我很确定我错过了一些基本的东西,但我不知道它是什么。一切都应该是默认字符集(我没有指定或更改任何内容),我假设是 Latin1。这应该没问题,因为我需要的所有字符都是 Latin1 (大多数问题似乎都是针对将字符集更改为 utf-8)。
我使用 charset=iso-8859-1 从 HTML 页面复制并粘贴,将一些带有尖音符和变音符号的字母插入到 MYSQL 数据库中,从命令行选择时显示正常。然而,我在 PHP 脚本中选择这些并使用 iso-8859-1 作为浏览器编码进行显示,它们仅显示为逗号或撇号。
ä = „ ö = ” é = ‚ á =(空白)
如果我只是将这些元音复制并粘贴到实际的 php 标签下方,它们就会正确显示。
I'm pretty sure I'm missing something basic, but I can't figure out what it is. Everything should be default characterset (I haven't specified or changed anything) which I assume is Latin1. This should be fine as all the characters I need are in Latin1 (most questions seem directed at changing charset to utf-8).
I used copy and paste from an HTML page with charset=iso-8859-1 to insert some letters with acutes and umlauts into a MYSQL database, which shows up fine when selected from the commandline. However well I select these in a PHP script and display with iso-8859-1 as the browser encoding, they show up as commas or apostrophes only.
ä = „
ö = ”
é = ‚
á = (a blank)
If I just copy and paste these vowels below the actual php tags, they display correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 htmlentities()
我认为这在过去对我有用。
Try using htmlentities()
I think that worked for me in the past.
确保您显示数据的位置具有
并且您的 MySQL 表已相应设置。我的设置为
MyISAM, latin1--cp1252 West European, latin1_spanish_ci
它解决了我的问题!(我使用 Navicat 将 Excel 工作表导入 MySQL,该工作表包含“á”等特殊字符。)
Make sure that where you're displaying your data has a
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
and that your MySQL table is set accordingly. Mine is set toMyISAM, latin1--cp1252 West European, latin1_spanish_ci
and it solved my problems!(I had imported an Excel sheet into MySQL using Navicat, and the sheet contained special characters like "á" and such.)