Re: innerHTML = responseText generates invalid chars



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. '&apos;' is one of the five default character entities in
XML besides '&quot;', '&amp;', '&lt;' and '&gt;'.

--
Bart

.



Relevant Pages

  • Why is LANG set to en_US.UTF-8?
    ... On Fedora FC3, when I use ssh to connect to the machine, the display ... is all garbled for single quote, double quote, and grave accent ... characters. ...
    (Fedora)
  • Re: Trouble reading fields containing special characters
    ... I double any possible single quote characters in the string. ... Any double single quotes in a string (all SQL strings are enclosed by single ...
    (microsoft.public.vb.database.ado)
  • Re: ~/.bashrc problem
    ... > Using " works most of the time, but, if you encouter some URL like ... However the expansion is done only once; characters inside the variable ... you must enclose it in single quote to prevent expansion of ...
    (Debian-User)
  • Re: SQL Injection Code Help
    ... The most important characters to get rid of are the single quote and ... If your application connects to SQL server with a SQL ... user that is a member of the sysadmin role, SQL injection could be very ... ' Replace globally disallowed characters: ...
    (microsoft.public.sqlserver.security)
  • Re: Character encoding problems reading Html from Clipboard
    ... characters and their distorted equivalents in the clipboard after being ... close single quote ...
    (microsoft.public.dotnet.framework.windowsforms)