nsmyself
nsmyself

Reputation: 3565

Opera and Safari aren't displaying latin1 characters

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

Upvotes: 0

Views: 842

Answers (1)

hallvors
hallvors

Reputation: 6229

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.

Upvotes: 1

Related Questions