UTF-8问题在Firefox - 响应头覆盖元标记? [英] UTF-8 issue in Firefox - response header overriding meta tag?

查看:174
本文介绍了UTF-8问题在Firefox - 响应头覆盖元标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下元标记的网页:

 < meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/> 

我认为这会将默认字符集设置为UTF-8, Safari,但不在Firefox中。



我在页面上有一个PHP脚本,它生成jPlayer的音频文件的播放列表,以及带有字符的字符的文件名不能在Firefox中工作/播放。 p>

这是我在Firebug控制台中看到的错误消息:





如您所见,文件名中的字符未读取正确。文件名应该是Guessi-Guéré-Guessi(Pop Bariba)



当我然后查找错误的更多详细信息,在标题 :



>



这说明字符集是iso-8859-1。然后在响应标签中,我看到:





这确认了错误,但这次使用正确的编码显示。该文件肯定存在,正如我说它在其他浏览器中播放/工作。



因此,我假设问题是与响应标头在Firefox中设置不同,并覆盖元标记。我已经检查了Chrome中的响应标头,它们确实设置为UTF-8。我可以做些什么来解决这个问题?

解决方案

事实证明,jPlayer Flash回退有一个问题。 Firefox使用Flash播放mp3。



以下是jPlayer开发人员的修复:



使用encodeURI (url)JavaScript命令在将URL传递给setMedia之前在JavaScript中对URL进行编码。例如:

  $(#id)。jPlayer(setMedia,{
mp3:encodeURI http://domain.com/audio/大地书房.mp3)
});


I have a page with the following meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

I thought this would set the default character set to UTF-8 and indeed it appears to in Chrome and Safari, but not in Firefox.

I have a PHP script on the page which generates a playlist of audio files for jPlayer, and filenames with accents in characters aren't working/playing in Firefox.

Here is the error message I am seeing in the Firebug console:

As you can see the characters in the filename aren't getting read correctly. The filename should be "Guessi-Guéré-Guessi (Pop Bariba)"

When I then look for more detail on the error, under the "Headers" tab I see this:

Which shows that the charset is iso-8859-1. Then in the "Response" tab I see:

Which confirms the error, but this time with the correct encoding showing. The file definitely exists, and as I say it plays/works in other browsers.

So I am presuming the issue is to do with the response headers getting set differently in Firefox, and overriding the meta tag. I have checked the response headers in Chrome, and they are indeed set to UTF-8. What can I do to fix this?

解决方案

It turns out that there was an issue with the Flash fallback in jPlayer. Firefox uses Flash to play the mp3.

Here's the fix from the developer of jPlayer:

Use the encodeURI(url) JavaScript command to encode the URL in JavaScript before passing the url to setMedia. For example:

$ ("#id").jPlayer("setMedia", {
   mp3: encodeURI("http://domain.com/audio/大地書房.mp3")
});

这篇关于UTF-8问题在Firefox - 响应头覆盖元标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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