在 PHP 中显示从 MYSQL 提取的数据的重音符号

发布于 2024-10-10 07:58:05 字数 353 浏览 0 评论 0原文

我很确定我错过了一些基本的东西,但我不知道它是什么。一切都应该是默认字符集(我没有指定或更改任何内容),我假设是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黄昏下泛黄的笔记 2024-10-17 07:58:05

尝试使用 htmlentities()

我认为这在过去对我有用。

Try using htmlentities()

I think that worked for me in the past.

轻许诺言 2024-10-17 07:58:05

确保您显示数据的位置具有 并且您的 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 to MyISAM, 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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文