Doug said:
I am serving one page, that starts with <html> and has the correct
charset header in it.
^^^^^
What you call a "correct charset header" here, is (due to the description
you provide of it) _not_ what is called a header in Internet messages at
all, but merely a HTML meta[http-equiv] element. This element, especially
with the `http-equiv' attribute value `Content-Type' (case-insensitive),
MUST be _ignored_ by a compliant HTTP/1.1 client if the respective HTTP
header was already sent by the HTTP server. (RFC2616, 3.4.1.)
Furthermore, a "page", which should be in fact a Valid HTML document, MUST
NOT start with `<html>' (RFC2854 "The 'text/html' Media Type", section 5,
explains that 'Almost all HTML files have the string "<html" or "<HTML"
_near the beginning_ of the file'.) HTML is an SGML application, therefore
a DOCTYPE declaration is required for a Valid HTML document prior to the
root element (here: html). This is explained in RFC2854, and specified in
the HTML 3.2, HTML 4.01 and ISO HTML specifications (where the latter is a
standardized version of HTML 4.01 Strict; HTML versions prior to 3.2, such
as HTML 2.0, are obsoleted by RFC2854.)
The XMLHttpRequest is returning text which I am using to set the
.innerHTML of a div section with.
It matters how the Japanese glyphs in the retrieved hypertext snippet are
referenced or encoded. If only character references or character entity
references are used therein, then there should not be a problem even if the
target document, that is, the document containing the `div' element, has a
different encoding. However, if the encoding of the target document and
the retrieved data differ and characters are not referred to as described,
the hypertext data, when included into the target document, is very likely
to be displayed garbled.
Where in this text would it make sense to store the charset of just the
snippet I am returning from the server.
Nowhere _in_ the text, that is, the message body. You should serve either
resource with the appropriate Content-Type _HTTP (message) header_ and
"charset" label as I suggested in my other followup. Due to the confusion
you display here about headers, it is probably a good idea if you learned
more about how HTTP works before; reading RFC2616 would be a good start.
Regards,
PointedEars