Forum Moderators: open

Message Too Old, No Replies

Tried to validate site

I get a utf-8

         

Junanagoh

9:06 pm on Dec 15, 2005 (gmt 0)

10+ Year Member



"Sorry, I am unable to validate this document because on line 77 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication."

Anyone know what I am doing wrong?

Robin_reala

9:53 pm on Dec 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check line 77 for weird characters. A common cause of this is MSs 'Smart Quotes' in text pasted from Word files.

Junanagoh

10:46 pm on Dec 15, 2005 (gmt 0)

10+ Year Member



If i pasted it from word into notepad?

I get the same error message for every page I have. I guess its something from the template i made. I keep looking it over but dont see anything out of the ordinary.

encyclo

11:29 pm on Dec 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I assume you're specifying UTF-8, but is the file really encoded as Unicode? If you are using Notepad it is very unlikely.

On the validator results page, change the encoding from "Detect automatically" and specify "windows-1252" instead. Does the page validate with that option selected?

Junanagoh

11:59 pm on Dec 15, 2005 (gmt 0)

10+ Year Member



Great :) I dont get that error now. Now its just telling me everything is wrong, these errors are weird. Am I missing something that should be in my head? Or am I using depreciated xhtml? Here is an copy of my head:

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<title>My Title</title>
<meta name="Description" content="widgets">
<meta name="Keywords" content="widgets">
<link rel="stylesheet" type="text/css" href="format.css" />

<script type="text/javascript">
"Script is here"
</script>

</head>

-------------------------

Examples of errors:

Error Line 9 column 58: character data is not allowed here.

<link rel="stylesheet" type="text/css" href="format.css" />

-----------------------------------------

Error Line 51 column 143: there is no attribute "BGCOLOR".

...pmargin="0" bottommargin="0" bgcolor="black">


Is there something that I am missing? This is my first website, lol.

encyclo

1:56 am on Dec 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error on line 9 is because you are missing the trailing slashes on your meta elements which are vital in XHTML. You should have something like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 [b]S[/b]trict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html [b]xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"[/b]>

<head>
[b]<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />[/b]
<title>My Title</title>
<meta name="Description" content="widgets"[b] />[/b]
<meta name="Keywords" content="widgets"[b] />[/b]
<link rel="stylesheet" type="text/css" href="format.css" />

<script type="text/javascript">
"Script is here"
</script>

</head>

Corrections are in bold - I have added a meta tag for the character encoding. Unless you encode the page as UTF-8 (which is ideal but very problematic if you are only using Notepad - most proper text editors can do it though) you should change the encoding to the one you are using. On the

html
tag, you should change
en
to the appropriate two-letter language code for your site's language.

For the other errors, the attributes

topmargin
,
leftmargin
etc. as well as
bgcolor
are either invalid or deprecated - you should be using CSS instead. Remove them and add the following to your stylesheet:

body {
margin:0;
padding:0;
color:#fff; /* or your text default color */
background:#000;
}

cuce

5:28 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



OOOOOOh I hate smart quotes.... GRRR

Junanagoh

6:19 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



thanks encyclo, ill try that out

Robin_reala

7:23 pm on Dec 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



smart quotes are great, but they need to be valid UTF-8 characters (or entites at a pinch). Just find a 'smart quote' and do a search and replace on it for &8216; (or &8217;, &8220;, or &8221;). Problem fixed.

Junanagoh

7:41 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



can you explain that in a little more detail?

I dont really understand any of it, lol.

AlexK

8:16 pm on Dec 16, 2005 (gmt 0)

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



A complicated issue. Here is a smidgen of PHP code to go from IE translations to (mostly) HTML entities to help keep my own pages validated:

function fFixIE( $str) { // fix IE entity/1252 conversions
$srch=array( "& ", "®", "©", "\x91", "\x92", "\x93", "\x94", "â", "ç", "ê", "ñ", "&#917;", "&#955;", "&#948;", "&#945;" );
$repl=array( "&amp; ", "&reg;", "&copy;", "&lsquo;", "&rsquo;", "&ldquo;", "&rdquo;", "&acirc;", "&ccedil;", "&ecirc;", "&ntilde;", "&Epsilon;", "&lambda;", "&delta;", "&alpha;" );
return str_replace( $srch, $repl, $str);
}

(Windows "smart quotes" and their entity equivalents are emboldened.)

Essentially, Windows uses (both) 8-bit and 16-bit Unicode at the kernel & API-level. Various MS apps (such as Word) will change quoted words to "smart quoted" words. That means that

"smart quoted"
will become
\x93smart quoted\x94
(or at least, that is what the research on my own site showed).

The above is not, in itself, a problem, but the issue of the character encoding *is* a problem. If either the server or the HTML declares your document to be UTF-8, but the document contains Windows "smart quotes" (which are "windows-1252" encoding) then it will fail validation.

A bit clearer?

Junanagoh

8:25 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



a bit :)

I changed it all and now get a few different error messages. I think I am using a wrong doctype (thats what one of the errors say)

[edited by: tedster at 9:08 pm (utc) on Dec. 16, 2005]

Junanagoh

10:23 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



I tested the doctype and it just comes up with different errors. Now I am getting 3 errors.

=================================

validator.w3.org/

This page is not Valid (no Doctype found)!
Below are the results of attempting to parse this document with an SGML parser.

Error Line 1 column 0: no document type declaration; implying "<!DOCTYPE HTML SYSTEM>".
<HTML><HEAD><META HTTP-EQUIV="Refresh" CONTENT="0.1; URL=/">
The checked page did not contain a document type ("DOCTYPE") declaration. The Validator has tried to validate with a fallback DTD, but this is quite likely to be incorrect and will generate a large number of incorrect error messages. It is highly recommended that you insert the proper DOCTYPE declaration in your document -- instructions for doing this are given above -- and it is necessary to have this declaration before the page can be declared to be valid.

&#9993;

Error Line 4 column 6: end tag for "HEAD" which is not finished.
</HEAD></HTML>
Most likely, You nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, <head> generally requires a <title>, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.

&#9993;

Error Line 4 column 13: end tag for "HTML" which is not finished.
</HEAD></HTML>

===========

Here is my script now:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Widgets</title>
<meta name="Description" content="Widgets"/>
<meta name="Keywords" content="widgets"/>
<link rel="stylesheet" type="text/css" href="format.css" />

<script type="text/javascript">
<!--
var time = 3000;
var numofitems = 3;
var menuYmin = 75;
var menuYmax = 175;

//menu constructor
function menu(allitems,thisitem,startstate){
callname= "gl"+thisitem;
divname="subglobal"+thisitem;
this.numberofmenuitems = numofitems;
this.caller = document.getElementById(callname);
this.thediv = document.getElementById(divname);
this.thediv.style.visibility = startstate;
}

//menu methods
function ehandler(event,theobj){
for (var i=1; i<= theobj.numberofmenuitems; i++){
var shutdiv =eval( "menuitem"+i+".thediv");
shutdiv.style.visibility="hidden";
}
theobj.thediv.style.visibility="visible";
}

function closesubnav(event){
if ((event.clientY <menuYmin)¦¦(event.clientY > menuYmax)){
for (var i=1; i<= numofitems; i++){
var shutdiv =eval('menuitem'+i+'.thediv');
shutdiv.style.visibility='hidden';
}
}
}
// -->
</script>
</script>

</head>

<body>

my ending tags:

</td>
</body>
</html>

========

Anything I am doing wrong?

encyclo

11:15 pm on Dec 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The page the validator is seeing is not the one above - it is trying to validate a redirect page instead (see the error mesage - the markup listed is not on your page).

Try installing the web developer toolbar for Firefox - you can validate a local page.

Junanagoh

11:42 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



Wow, great! Thanks.