Charsets and black diamonds on Firefox -- but NOT IE
Posted by: JRWoodward (216.173.165.---)
Date: September 15, 2008 06:49AM

I use WAMP Version 2.0 configured with Apache 2.2.8, PHP5.2.6 and MySQL5.0.51b.
I am developing a website that I have been testing by opening the file directly using Firefox' "Open File" feature.
The website is a three-column CSS design with buttons on both the left and right columns. When a user clicks
a button on the right, a javascript AJAX script replaces the information in the center column with a text files.
The files have some basic markup in them: <h2>, <p>, <ul> and <li> tags. There is no javascript or CSS in the
replacement files.
Today I moved the web folders to the WAMP www folderf. When I use Internet Explorer or the Firefox "Open File" feature,
the AJAX script loads the pages and they display correctly. When I use the htt://localhoast/ URL to load the pages,
Firefox displays a page of black diamonds with white question marks inside them. There are also a few other characters that
I hav never seen before: little square boxes with tiny numbers displayed in them like this:

__
|00|
|13|
--

For what it's worth, the little boxes are numbered 0013 and 0014. All the text that is in the file is displayed, content and
tags. Even the spaces are displayed. Next to each character, there is a black diamond with the white question mark. Even the
spaces are there. By tinkering with the text, I have determined that the black diamonds display to the left of the correct character --
just before it. If I style the text in color, the black diamonds appear in the correct color. The correct charachters display in
some sort of default Times Roman font, which is not the one coded for in the CSS.

This ONLY appears if I load the page into Firefox (I am using the new 3.0.1) from the WAMP server, not if I load it directly
from the Windows Vista Business file system. The page displays correctly in Internet Explorer.

Here are some of the things I have tried:

Firefox -- set View > Character Encoding > AutoDetect > Universal
set View > Character Encoding > Western ISO 8859-1
set View > Character Encoding > Western ISO 8859-15
set View > Character Encoding > UTF-8

Interestingly, I find that whatever I set Firefox at, it always switches to UTF-16 Little Endian after I load the page.
Other pages loaded in other tabs are not affected.

APACHE -- I tried entering a "AddDefaultCharset" directive with Western ISO 8859-1 and then changed it to UTF-8; no luck.
I tried "AddDefaultCharset On" which according to the directives documentation page at apache.org should have forced Western ISO-8859-1.
I also tried "AddCharset UTF-8" when I had Firefox set to UTF-8 but that did not work.

I used the Firefox plug-in Live Headers to trap the headers sent by Apache. I snipped stuff like keep=alives and referers.
All my edits to httpd.conf have been removed.

[localhost]

GET /fra/ HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1; .NET CLR 3.0; ffco7) Gecko/2008070208 Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

HTTP/1.x 304 Not Modified
Date: Mon, 15 Sep 2008 04:19:53 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.6
Etag: "8b0000000026c0-2894-456e640e27af9"
----------------------------------------------------------
[localhost]

GET /fra/css/FRA_CSS.css HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1; .NET CLR 3.0; ffco7) Gecko/2008070208 Firefox/3.0.1
Accept: text/css,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7


HTTP/1.x 304 Not Modified
Date: Mon, 15 Sep 2008 04:19:53 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.6
[localhost]

GET /fra/javascript/fra.js HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1; .NET CLR 3.0; ffco7) Gecko/2008070208 Firefox/3.0.1
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

HTTP/1.x 304 Not Modified
Date: Mon, 15 Sep 2008 04:19:53 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.6
[localhost]

GET /fra/Getting_Started.htm?1221452421644 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1; .NET CLR 3.0; ffco7) Gecko/2008070208 Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

HTTP/1.x 200 OK
Date: Mon, 15 Sep 2008 04:20:22 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.6
Last-Modified: Mon, 15 Sep 2008 03:32:48 GMT
Etag: "d00000001a837-7532-456e6e3a84df9"
Accept-Ranges: bytes
Content-Length: 30002
Content-Type: text/html
------------------------------------------------------------------------

The headers from the User Agent (Firefox) contains these strings:

Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

So, if I'm not mistaken, Firefox is saying it can read ISO-8859-1 and UTF-8, but Apache is sending
something else -- which Internet Explorer can read, but Firefox cannot. Remember, Firefox says the
document is "UTF-16 Little Endian." Apparently IE uses "Encoding Autodetect" to read the page as
"Western European left-right-document".

Looking at live headers for other pages, I see things like this coming from the httpd server:

Content-Encoding: gzip
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

So Apache can send this data to Firefox if it is configured to do so. It isn't sending charset data
now. Would this solve my problem, and if so, how do I implement it?

I hope someone can help me with this because otherwise I will have to start using IE as my development environment -- ugh, ycuk! smiling smiley

If the Javascript matters, here it is:

var request = null;
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="["+window.location.hostname]
var bustcacheparameter=""

function ajaxpage(url){
var page_request = false
if (window.XMLHttpRequest) page_request = new XMLHttpRequest() // if Mozilla, Safari etc
else if (window.ActiveXObject){try {page_request = new ActiveXObject("Msxml2.XMLHTTP"winking smiley} // if IE
catch (e){try{page_request = new ActiveXObject("Microsoft.XMLHTTP"winking smiley}
catch (e){} }}
else return false
page_request.onreadystatechange=function(){loadpage(page_request)}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?"winking smiley!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http"winking smiley==-1))
document.getElementById('centercol').innerHTML=page_request.responseText
}

Options: ReplyQuote


Sorry, only registered users may post in this forum.