0

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

João Pereira
  • 3,545
  • 7
  • 44
  • 53

1 Answers1

1

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.

hallvors
  • 6,069
  • 1
  • 25
  • 43
  • (Or, of course, Content-type: text/javascript; charset=UTF-8 - the MIME type isn't important for this purpose, the charset is.) – hallvors Nov 21 '11 at 11:46
  • The headers were fine. We ended up converting everything in the server-side Ruby on Rails backend using URI encode and we solved the issue. I'm accepting your answer anyway, thank you for helping me. – João Pereira Dec 11 '11 at 11:16