Results 1 to 6 of 6

Thread:   and strict html validation

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default   and strict html validation

    Hi. In short I am trying to validate my site. It is a long process. I am going from transitional to strict. I have a code that $summary to htmlentities, preg_replaces sets of two spaces into    and then I use html_entity_decode to change it back.

    The problem is that the w3 validator won't validate it because of the   PHP.net has this note about using   that I don't quite understand
    ' ' entity is not ASCII code 32 (which is stripped by trim()) but ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.
    html_entity_decode()

    The failure statement reads
    Sorry, I am unable to validate this document because on line 1 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.

    The error was: utf8 "\xA0" does not map to Unicode
    Any ideas on what I can do? I would prefer to keep the   if I can, so that the browser doesn't condense sets of spaces when I don't want it to.

    I am using
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
    EDIT: Sorry, I got it. Instead of using &nbsp; I am going to use & #160; (without the space between the & and #. The forum won't display the pattern I see.)&#160; problem solved. Now I am off to revalidating. This will certainly take a while.
    Last edited by james438; 08-23-2007 at 10:15 PM.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    either way it would be stripped...
    you can use

    PHP Code:
    htmlspecialchars($tring)
    or
    htmlentities($tring

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Maybe so, but it won't validate, which is why I changed to & #160;
    Last edited by james438; 08-24-2007 at 10:32 PM.

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Unfortunately another problem crops up when I convert to php5. The & #160; and & nbsp; coverts to those black diamonds with question marks on them. Any ideas? My best guess is that I need to specify a different character set, but I am not sure how to figure that out.

    This is almost something for a different thread, but it seemed close enough that I just tacked it onto the end of this thread.
    Last edited by james438; 08-24-2007 at 10:31 PM.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    In Unicode I believe it's &#00A0;.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    hate to give you a partial solution to this, but I went back to my script and was having a bit of difficulty reproducing the error, but along the way I noticed that I could get rid of htmlentities($text) and the html_entity_decode() and it would validate again. That is when I noticed that the error was coming from html_entity_decode(). I don't really know why or what html_entity_decode was decoding &nbsp; into, but the script works now.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •