The server side also includes character encoding

I created a static website in which each page has the following structure:

  • Common things like heading, menu, etc.
  • Page content in main content div
  • Footer

On this website, all shared content is duplicated on every page. To improve maintainability, I reorganized the pages for server-side use (SSI) so that shared content is not duplicated. The structure of each page is now

  • SSI for ordinary things like heading, menu, etc.
  • Page content in main content div
  • SSI for footer

On a refactored site, for some reason, French characters are no longer displayed properly in the page-specific content area, although they do display content enabled via SSI well.

An included header indicates the character set as:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

If I open one of the main content pages in a browser, it will tell me that the character encoding is ISO-8859-1. I tried adding the .htaccess file to the lines folder

 AddDefaultCharset UTF-8 AddCharset UTF-8 .shtml AddCharset UTF-8 .html 

But still, these annoying French accents do not display properly in the SSI version of the site.

+4
html character-encoding server-side-includes ssi
source share
3 answers

You serve your pages as UTF-8, which is good, but at least part of the page is dragged from files that are not actually saved as UTF-8. SSI just throws away the raw bytes, it does not try to recode the incoming so that their encodings match the file in which they were included.

You need to go through all your html and include the files in a text editor and make sure that each of them is saved as UTF-8.

As John mentioned, you can avoid encoding problems by using character references for all non-ASCII characters, but this is a huge pain.

+3
source share

Your HTML document uses UTF-8 encoding, try these character codes for your accented letters: http://www.tony-franks.co.uk/UTF-8.htm

0
source share

I had the same problem as you and finally found a solution that fixed it.

UTF8 does an extra line on my site

Save all your files as UTF-8 without specification ( http://en.wikipedia.org/wiki/Byte_order_mark ).

0
source share

All Articles