3

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:

enter image description here

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:

enter image description here

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

enter image description here

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?

Nick
  • 4,304
  • 15
  • 69
  • 108
  • 1
    It looks like this response header is for the actual 404 error page, not the playlist page. You can check the current page encoding from the Firefox menu -> Web developer -> Character encoding. – Vatev Jul 21 '12 at 15:52
  • 1
    What exactly does the PHP script output for `é`? Does it output `%E9`? If you want to be as compatible as possible, the correct UTF-8 sequence would be `%C3%A9` – Mr Lister Jul 21 '12 at 16:10
  • @Vatev I'm running the latest version of FF on a Mac and don't see that menu. I do see Tools -> Page Info, which states that the encoding is UTF-8. – Nick Jul 21 '12 at 16:35

2 Answers2

1

The URL alias http://monthlymixup.com/mixups/july_2012/media/nick/Guessi-Gu%C3%A9r%C3%A9-Guessi%20%28Pop%20Bariba%29.mp3 works OK on Firefox, too. So the problem is appearently on the linking page. The problem can be reproduced using the following test page:

<!doctype html>
<title></title>
<meta charset=iso-8859-1>
<a href=
"http://monthlymixup.com/mixups/july_2012/media/nick/Guessi-Gu%e9r%e9-Guessi%20%28Pop%20Bariba%29.mp3"
>link</a>

Thus, the problem is in the PHP code that generates the linking page. It seems to % encode the letter “é” on its own, using the ISO-8859-1 based encoding %e9 instead of the proper UTF-8 based encoding.

Make sure that the linking page is generated correctly, with the letter “é” rather than any % encoded form or the UTF−8 based encoding %C3%A9.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • Whether or not links to file system resources should be interpreted according to the coding system of the linking page is IMHO debatable. What are the actual bytes in the file name on the server? – tripleee Jul 22 '12 at 07:02
1

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")
});
Nick
  • 4,304
  • 15
  • 69
  • 108