Opera 和 Safari 不显示 latin1 字符

发布于 2024-12-16 11:41:08 字数 895 浏览 3 评论 0原文

我在最新版本的 Safari 和 Opera 中显示拉丁字符(例如“ç”、“ã”或“À”时遇到问题)。我使用 Ajax 和 JQuery(Latin1 字符集)从 ​​RoR 后端接收数据(JSON),并且网页本身依赖于 Latin1,这要归功于:

<?php header('Content-Type: text/html; charset=ISO-8859-1');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml"
      lang="pt">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>

当我执行包含大约 10 个命令时,我制作的自定义 Javascript 库还专门声明了 ISO-8859-1 lines later on:

    <script type="text/javascript" src="js/lib.js" charset="ISO-8859-1"></script>

尽管如此,两个浏览器都无法显示之后的字符。 Safari 显示了臭名昭著的黑钻石,而 Opera 只是显示了一个空白区域。

有什么想法吗?提前致谢

I'm having trouble displaying latin1 characters such as "ç", "ã" or "À" in the latest versions of Safari and Opera. I receive data (JSON) from a RoR backend using Ajax and JQuery (Latin1 charset) and the webpage itself relies on Latin1, thanks to:

<?php header('Content-Type: text/html; charset=ISO-8859-1');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml"
      lang="pt">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>

The custom Javascript lib i made also specifically states ISO-8859-1 when I perform the include some ten lines later on:

    <script type="text/javascript" src="js/lib.js" charset="ISO-8859-1"></script>

Nevertheless, both browsers fail to display the characters afterwards. Safari shows the infamous black diamond, while Opera simply shows a blank space.

Any ideas? Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

千秋岁 2024-12-23 11:41:08

您的内容类型中发送的字符集很可能是错误的:JSON 数据的 HTTP 标头。在您的帖子中,您显示了页面本身和包含的脚本的标题和 META 标记,但假设 JSON 数据是单独发送的,它将被单独标记。获得存在此问题的页面的链接会有所帮助,但如果您不想发布该页面,则可以使用 Microsoft Fiddler HTTP 调试器之类的工具来检查浏览器和浏览器之间来回发送的标头。网站。如果 Web 服务器发送的

  Content-type: text/html;charset=UTF-8

文件内容为“拉丁语”(iso-8859-1),反之亦然,那就是您的问题。修复 HTTP 标头就可以了。

Most likely wrong charset sent in your Content-type: HTTP header for the JSON data. In your post you show the headers and META tags for the page itself and the included SCRIPT, but assuming the JSON data is sent separate it will be labelled separately. It would help to get a link to a page with this problem, but if you don't want to post one you can use a tool like Microsoft Fiddler HTTP debugger to inspect the headers that are being sent back and forth between the browser and the web site. If the web server sends

  Content-type: text/html;charset=UTF-8

for a file with content in "latin" (iso-8859-1) or vice versa, that's your problem. Fix the HTTP header and you'll be fine.

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