Forum Moderators: open

Message Too Old, No Replies

Document Encoding for Thousands of pages

         

omerkh

9:43 am on Sep 13, 2007 (gmt 0)

10+ Year Member



Hi,

I have a website with over two-thousand shtml pages (use SSI for document header and footer for uniform look and feel). I have not been using any meta-tags to declare my document type or character encoding.

Is there a short-cut for me so I can add this info to my documents without having to update each and every page manually?

I am already using:
@charset "UTF-8";
in the css for each page.

regards

Marshall

9:58 am on Sep 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If your header SSI provides all <head> information: <html> <head> </head> <body>, and your footer SSI provides </body> </html>, you should be able to insert into the header SSI at the top the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

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

If, however, your header SSI only provides information below the <body> tag, then unless you have an editor that provides a "find and replace" feature, you will have to do it manually.

Marshall

penders

1:15 pm on Sep 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...to declare my document type or character encoding.

This information can be sent as part of the HTTP response header from the server and is in fact probably the prefered way to serve this information as it will take priority over META tags in the HTML.

On Apache, I believe (not tried it) you can modify your .htaccess file in your root to do this. This will effect every page on your site, including sub directories.

Something like:

AddType 'text/html; charset=UTF-8' html

...to effect all .html files.

From the W3C:
[w3.org...]

encyclo

1:16 am on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld omerkh.

As penders above has indicated, you can declare the charset via HTTP headers rather than in the page itself. If the entire site is encoded with the same charset, then you can use the

AddDefaultCharset
(assuming your server is running Apache):

[httpd.apache.org...]

pageoneresults

1:33 am on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As penders above has indicated, you can declare the charset via HTTP headers rather than in the page itself.

Ah, I've been meaning to ask this question. I've tested using http headers in IIS. While I think everything was done properly, its a fairly simple process, the pages would not validate due to a missing charset element. Maybe its an IIS thing and I'd like to find out why. If I can remove that element from my pages, I'm fine with that. But, what happens if that page is served from somewhere besides my server? Wouldn't you want that page to be portable and pack that charset element right up there after the <head> and before the <title> element?

penders

12:48 pm on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...the pages would not validate due to a missing charset element.

A META Content-Type (ie. charset) element, although possibly good practise, is not required for valid markup. I can only think that if the server also failed to return a Content-Type header then a validator would complain...?

But, what happens if that page is served from somewhere besides my server?

I suppose that's where the 'good practise' of including a Content-Type META element comes in. But there may be other elements on your page that are dependent on your server, a database perhaps. So viewing your page away from your server may not be strictly relevant. Although, I guess in order to view a snapshot/static HTML version of your page, then the Content-Type META element is probably still required.