Re: innerHTML = responseText generates invalid chars
- From: "rabbitrun@xxxxxxxxx" <rabbitrun@xxxxxxxxx>
- Date: Tue, 19 Feb 2008 05:56:39 -0800 (PST)
Actually the single quote is some sort of backward single quote.
There are also other characters not displaying correctly after
innerHTML = responseText.
I'll try to cover all the steps you noted above.
On Feb 19, 7:45 am, Bart Van der Donck <b...@xxxxxxxxxx> wrote:
Martin Honnen wrote:
rabbit...@xxxxxxxxx wrote:
When I assign responseText to innerHTML, sometimes because of the
content Firefox would display invalid characters using ? as a
placeholder. This is especially true for single quotes from text
content coming from a windows machine vs unix machine.
Does anyone comes across this frequently? What can I can do to make
the characters display properly?
Make sure the server sends a HTTP Content-Type response header with a
charset parameter e.g.
Content-Type: text/plain; charset=Windows-1252
Windows-1252 is only an example, obviously you need to set the encoding
there that your text is encoded with.
Adding 'charset=' is always a good idea, but I would avoid the
proprietary Windows-1252, especially because the original poster
surmises it is a Windows/UNIX issue.
I suggest to add a character set at the following places:
1. HTTP header of the program that outputs the data:
Content-Type: text/html; charset=ISO-8859-1
2. Inside the output file itself:
<?xml version="1.0" encoding="ISO-8859-1"?>
3. HTTP header of the receiving HTML-file:
Content-Type: text/html; charset=ISO-8859-1
4. As <meta> in the header of the receiving HTML-file:
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
The original poster mentions that it [quote] "is especially true for
single quotes from text content". Since single quote is an ASCII-safe
character, it makes me think that it has something to do with the DTD
of the XML. ''' is one of the five default character entities in
XML besides '"', '&', '<' and '>'.
--
Bart
.
- Follow-Ups:
- Re: innerHTML = responseText generates invalid chars
- From: Bart Van der Donck
- Re: innerHTML = responseText generates invalid chars
- References:
- innerHTML = responseText generates invalid chars
- From: rabbitrun@xxxxxxxxx
- Re: innerHTML = responseText generates invalid chars
- From: Martin Honnen
- Re: innerHTML = responseText generates invalid chars
- From: Bart Van der Donck
- innerHTML = responseText generates invalid chars
- Prev by Date: Re: Find Element Position
- Next by Date: Re: need modal
- Previous by thread: Re: innerHTML = responseText generates invalid chars
- Next by thread: Re: innerHTML = responseText generates invalid chars
- Index(es):
Relevant Pages
|