Topic
No replies
SystemAdmin
SystemAdmin
162 Posts
ACCEPTED ANSWER

Pinned topic How does the browser interpret the response inputstream sent by the server?

‏2007-11-10T13:19:11Z |
Hi everyone, lately a seems self-contradictory puzzle afflicted me.
We know when we use a browser to open a web page, the browser sends a request to the server asking for the required resources. If the server finds the resource, it sends the resource back as a response inputstream. The inputstream can be coded in different charsets such as UTF-8 or some local charset. If the browser wants to display the webpage correctly, it must decodes the inputstream with correct charset. The HTML often specifies the charset in its “meta” tag like:
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
Then I am puzzled that if I want to interpret the webpage right, I must get the right charset in advance. But if I want to get the charset first in advance, I must interpret the webpage first. Isn’t this self-contradictory?
Can anyone tell me how the browser chooses the decoding styles for the differently encoded web pages? I know apart from the HTML file the server sends HTML header also. Does that help? If the charset is specified in the header, then what use to set the charset again in HTML file?
Can anyone explain this?
Many thanks!