[英]Displaying accents in PHP on data pulled from MYSQL
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.
一切都应该是默认的字符集(我没有指定或更改任何内容),我认为它是Latin1。 This should be fine as all the characters I need are in Latin1 (most questions seem directed at changing charset to utf-8).
这应该没问题,因为我需要的所有字符都在Latin1中(大多数问题似乎都针对将字符集更改为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. 我使用从具有charset = iso-8859-1的HTML页面进行复制和粘贴的方式,将一些带有尖音和变音符号的字母插入到MYSQL数据库中,当从命令行中进行选择时,它显示得很好。 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.
无论如何,我在PHP脚本中选择了这些,并以iso-8859-1作为浏览器编码显示,它们仅显示为逗号或撇号。
ä = „ ö = ” é = ‚ á = (a blank) ä=„ö=”é=,á=(空白)
If I just copy and paste these vowels below the actual php tags, they display correctly. 如果我只是将这些元音复制并粘贴到实际的php标签下,它们将正确显示。
Try using htmlentities() 尝试使用htmlentities()
I think that worked for me in the past. 我认为过去对我有用。
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. 确保在显示数据的位置具有
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
并相应地设置了MySQL表。 Mine is set to MyISAM, latin1--cp1252 West European, latin1_spanish_ci
and it solved my problems! 我的设置为
MyISAM, latin1--cp1252 West European, latin1_spanish_ci
,它解决了我的问题!
(I had imported an Excel sheet into MySQL using Navicat, and the sheet contained special characters like "á" and such.) (我已使用Navicat将Excel工作表导入MySQL,工作表中包含特殊字符,如“á”等。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.