[thelist] ?xml &c. declaration

Dmytro Borovsky thelist at web-artel.net
Wed Jun 19 14:09:00 CDT 2002


> Can anyone on thelist give me a good reason for using the xml declaration,
(ie
> <?xml version="1.0" encoding="iso-8859-1" ?>) in a page?

>  I'd like to leave this line in, as it
> *is* part of the recommendation for XHTML (or seems to be; see
> http://www.w3.org/TR/xhtml1/#docconf under the "example of a minimal XHTML
> document."), but I can't think of any reason I should leave it in.

The declaration MUST be used when your document encoding is not some sort of
Unicode (usually, UTF-8).
You should just save your document as UTF-8 and remove the declaration.



<tip type="Multi-Lingual Web Site" author="Dmytro Borovsky">

When you’re working with multi-lingual Web pages, the easiest solution is to
save different languages in the same UTF-8 file and use a language selector.

Example (PHP based; selects language according to Accept-Language HTTP
request header (i. e. customized by users in their browsers); if language is
not supported, English is used):

<?php
Header('Content-Type: text/html; charset=UTF-8');
$languages = explode(',', strtoupper($HTTP_ACCEPT_LANGUAGE));
$languages[count($languages)] = 'EN';
$XHTMLSent = false;

for ($i = 0; $i < count($languages); $i++) {
 if ($XHTMLSent)
  break;
  $languages[$i] = substr($languages[$i], 0, 2);

 switch ($languages[$i]) {
  case 'EN':
   echo "English Text";
   $XHTMLSent = true;
   break;

  case 'UK':
   echo "Ukainian Text";
   $XHTMLSent = true;
   break;
 }
}
?>


http://www.web-artel.net/ is based on similar technology and displays Web
pages in two to four different languages.
</tip>

The code shown above was copied from http://www.iskander.com.ua/ Web site.


Kind regards.
Dmytro Borovsky.
Web Studio http://www.web-artel.net/




More information about the thelist mailing list