Page 1 of 1

[Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-10-09, 03:32
by markfilipak
Solution: https://forum.palemoon.org/viewtopic.php?f=37&t=9809&p=70799#p70799


Hi All. I'm posting a page on my server, but the ANSI code point 0xE5 isn't being rendered properly (note that ANSI == windows-1252). I can't figure out why. Here's the top of the page.

Code: Select all

<!DOCTYPE html><html><head><meta http-equiv="Content-Type"content="text/html; charset=windows-1252"><style type="text/css">i{font-family:serif;font-size:1.1em}p{padding:0 0 0.5em 0;margin:0}</style></head><body style="background-color:gray;font-family:sans-serif;font-size:12pt"><div style="background-color:white;width:40em;margin:0 auto;padding:12pt">
It seems that the "windows-1252" is not being honored. It's being honored for other peoples' pages, but not mine. :cry:

When I load the page and click View > Character Encoding, 'UTF-8' is selected. If I change it to 'windows-1252' (or to 'ISO-8859-1'), the page renders properly, including ANSI code point 0xE5, but if I reload the page, it screws up again.

I changed the character from 'å' to '&aring;' as a work-around, but I'd really like to know what's going on. Got any ideas?

Thank You.

Re: ANSI (windows-1252) not rendered properly

Posted: 2015-10-09, 04:03
by squarefractal
You may want to check whether your server is giving out conflicting information in the headers about the encoding of the HTML file.

Re: ANSI (windows-1252) not rendered properly

Posted: 2015-10-09, 05:33
by markfilipak
squarefractal wrote:You may want to check whether your server is giving out conflicting information in the headers about the encoding of the HTML file.
Good idea, but the code I posted is the header as shown in "View Page Source".

Re: ANSI (windows-1252) not rendered properly

Posted: 2015-10-09, 07:07
by squarefractal
"Header" as in "the HTTP Content-type: header" sent by the server, not the <meta> tag inside the <head> section of the HTML document.

Re: ANSI (windows-1252) not rendered properly

Posted: 2015-10-09, 16:58
by markfilipak
squarefractal wrote:"Header" as in "the HTTP Content-type: header" sent by the server, not the <meta> tag inside the <head> section of the HTML document.
Well, you're pretty smart...

Code: Select all

HTTP/1.1 200 OK
Date: Fri, 09 Oct 2015 16:52:53 GMT
Server: Apache
Last-Modified: Fri, 09 Oct 2015 03:17:21 GMT
Etag: "d7010-3502-6aef3240"
Accept-Ranges: bytes
Content-Length: 13570
Connection: close
Content-Type: text/html; charset=UTF-8
captured by Live HTTP Headers plug-in.
I don't know how to change that at the server, so I'll just have to live with it.

Re: ANSI (windows-1252) not rendered properly

Posted: 2015-10-10, 12:37
by squarefractal
If you're using a hosting service that allows you to change the server configuration, look into its configuration files. For Apache, look here:
https://stackoverflow.com/questions/913 ... for-server

Re: ANSI (windows-1252) not rendered properly

Posted: 2015-10-10, 16:06
by markfilipak
squarefractal wrote:If you're using a hosting service that allows you to change the server configuration, look into its configuration files. For Apache, look here:
https://stackoverflow.com/questions/913 ... for-server
Actually, it's my own server.

UTF-8 is fine with me. I have a text editor that allows me to write UTF-8, so I configured it and my problem's solved.

Thanks for your help. You provided the guidance I needed regarding HTTP headers. Mystery solved.

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-22, 19:10
by markfilipak
My server puts out UTF-8. That is, the HTTP headers include a 'Content-Type: text/html; charset=UTF-8' directive. In contrast, the HTML pages on my server specify '<meta http-equiv="Content-Type"content="text/html; charset=windows-1252">'. So as you see, the server's HTTP header and the HTML 'meta'-tag are colliding. Apparently, the HTTP header is winning. The result: ANSI (windows-1252) characters are being interpreted as UTF-8 (which causes the characters past 7F (hex) to be botched). I've changed all my server HTML source text to UTF-8 and changed the '<meta http-equiv=...>' HTML-tag to this: '<meta http-equiv="Content-Type"content="text/html; charset=UTF8">'. But this makes me wonder what good is a '<meta http-equiv=...>' tag if browsers are going to ignore it. Ah, well...

PS: I guess I was thinking that a '<meta http-equiv=...>' HTML tag created an override (changing the text specification from the server's 'UTF-8' to the web page's 'windows-1252'). I guess a '<meta http-equiv=...>' HTML tag is NOT an override, but is instead meant to cover situations in which the server does not specify any encoding in its HTTP headers.

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-22, 19:13
by New Tobin Paradigm
HTTP headers take precedence over what the content says it is. This I believe is correct spec behavior. That's why.

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-22, 19:18
by markfilipak
Matt A Tobin wrote:HTTP headers take precedence over what the content says it is. This I believe is correct spec behavior. That's why.
Hi Matt,

You posted this while I was adding my PS. What do you think of the PS? Regards - Mark.

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-22, 19:38
by New Tobin Paradigm
Yeah, the only thing to add to your PS is.. Also situations where there isn't actually a server as well :thumbup:

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-22, 20:13
by markfilipak
Matt A Tobin wrote:Yeah, the only thing to add to your PS is.. Also situations where there isn't actually a server as well :thumbup:
Well, I know some things, but I'm shockingly ignorant of other things ... for the sake of my education, I must ask: how can web pages be served without a server?

Thanks!

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-22, 21:00
by New Tobin Paradigm
Open them locally (technically open them from a filesystem local or network) :P

Re: [Solved] ANSI (windows-1252) not rendered properly

Posted: 2015-11-23, 00:22
by markfilipak
Matt A Tobin wrote:Open them locally (technically open them from a filesystem local or network) :P
Duh! ...And I thought you were going to cite something stunning. Hahahahahahahaha... (just having some fun with you -- Ciao, & Thanks).