HighDots Forums  

Re: read charset of meta tag

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: read charset of meta tag in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
optimistx
 
Posts: n/a

Default Re: read charset of meta tag - 08-28-2008 , 07:17 AM






Martin Honnen wrote:
....
Quote:
On the other hand most browsers by now expose a property like
document.characterSet (Mozilla) or document.charset (IE) which should
give you the charset the browser has taken from the meta or from real
HTTP headers.
Is it true that these metatags have often different values compared to what
the browser actually uses? And the page author might have not a correct idea
of the character set, which the server is sending, thus believing that
putting something to metatags the server obeys him/her. The browsers in this
mess try to conclude the character set by examining the byte stream with
heuristic rules, getting often somewhat correct results.
I thought earlier that metatags are commands to the server: if I put
ISO-8859-10 to the tag, then the server transforms the page to that
characterset!

Eg javascript files on the server: I suspect most authors here have not 100
% reliable and true info which characterset they have. At least I have not





Reply With Quote
  #2  
Old   
Richard Cornford
 
Posts: n/a

Default Re: read charset of meta tag - 08-28-2008 , 08:37 AM






optimistx wrote:
Quote:
Martin Honnen wrote:
...
On the other hand most browsers by now expose a property
like document.characterSet (Mozilla) or document.charset
(IE) which should give you the charset the browser has
taken from the meta or from real HTTP headers.

Is it true that these metatags have often different values
compared to what the browser actually uses?
That is certainly possible as that browser will follow the HTTP headers
and take any character set declarations in the headers in preference to
anything else (as it required in HTTP). And it is certainly common for
the attributes of META elements to be at odds with HTTP headers (and
even at odds with document mark-up; how often do you see XHTML mark-up
contain a META element that attempts to assert that document to be
textt/html?).

Quote:
And the page author might have not a correct idea of the
character set, which the server is sending, thus believing
that putting something to metatags the server obeys him/her.
Yes, misconceptions about web technologies are rife.

Quote:
The browsers in this mess try to conclude the character set
by examining the byte stream with heuristic rules,
That has been observed (particularly with IE (at least up until 6)).

Quote:
getting often somewhat correct results.
And some spectacularly wrong result, hence the observation of the
phenomenon.

Quote:
I thought earlier that metatags are commands to the server:
For some servers they have been; the server would process the document
prior to sending and base the headers used on the META elements. But
that is not very common with servers.

Quote:
if I put ISO-8859-10 to the tag, then the server transforms
the page to that characterset!

Eg javascript files on the server: I suspect most authors here
have not 100 % reliable and true info which characterset they
have.
Observing that some people don't know what they are doing is no reason
to assume 'most here' do not.

Quote:
At least I have not

Get yourself a web debugging proxy (Fiddler or Charles) or some other
tool that can show you the HTTP headers.

Richard.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.