Jump to content

Encoding and Validating


scottybwoy

Recommended Posts

I seem to have stumbled upon an issue, that I have been trawling around the web for only to return with more confusion.

 

I tried running W3C HTML Validator on this e-commerce site I've been working on, and it returned this error :

Sorry, I am unable to validate this document because on line 284  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 "\xA3" does not map to Unicode

 

I had a look at the output and line 284, it is just a comment block, like many others in the same file.  I tried converting the php file to UTF8 encoding but that just cocked up how the file executed (strange).  But I really don't know what the problem is.  All other sites php generated pages can be validated.  My doctype declaration is correct.  Could is be something to do with the server?

 

I'm really lost, anyone solved this before?

Link to comment
Share on other sites

We have run into similar things with character and byte reading issues at work, because we have to keep all our stuff unicode compliant for our internationalization. Out of curiosity, what is contained within the comment block (non-alpha characters, specifically). If I remember right, /xa3 is a pound sign, but I can't remember for sure. It seems as though the output to the page is not utf-8 compliant. It is also possible that the W3C validator may have the wrong mapping for a specific character (unlikely but possible). If you don't mind posting the comment block, that may help some.

Link to comment
Share on other sites

The comment block is fairly standard

<!-- footer //-->

 

Although one guy did have the same issue, deleted the comment block and left a blank line, and it still reported an error on that line.

 

I posted a link to the site, so people can see for themselves what is going on.  Thanks.

Link to comment
Share on other sites

OK, for kicks, let's just ignore the line number for a minute, because who knows what the validator does to break up the code. From my quick Google search, it seems that your error is on the pound symbol on your pages. The following code supposedly puts out a valid pound symbol:

<?php echo utf8_encode("\xa3"); ?>

 

That's the value you're getting in your error, too... Anywhere you're trying to echo utf8 compliant characters differently? I know it's a shot in the dark, but it's worth a try.

Link to comment
Share on other sites

Hi Obsidian,

 

Sorry I've been doing other stuff, but I have come back to it and found that when I replace the pound sign with what you suggested, it displays the '£' symbol.  Sorry, I'm not to hot on this area and am getting confused as to what parts get encoded when and for where?

 

Thanks for your help though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.